mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Description2
synced 2024-11-23 22:33:34 +00:00
c146909532
With this change, generated descriptions are cut at 300 characters, without breaking words when possible, and with an ellipsis added in case the cut happened mid-sentence. The `Description2::getFirstChars` function was borrowed from TextExtracts with minor alterations (added comment for their regex, and removed `>` from word healing given it's unclear why it's been included). New configuration variable `$wgDescriptionMaxChars` (proposed default: 300, which seems like a sensible amount) controls this behaviour. This has been in testing on ark.wiki.gg (with the platform's approval, which I'm glad for) since early September. Without this change, we had a few pages with little sections having a huge part of their body text thrown into the `description` meta tag... Depends-On: I585f2c0046571310aad67f3ba148c4f22aaae49f Change-Id: I04b00f99085f07f773212ee3eca8470eece34e9e
14 lines
361 B
PHP
14 lines
361 B
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\Description2;
|
|
|
|
interface DescriptionProvider {
|
|
/**
|
|
* Extracts description from the HTML representation of a page.
|
|
*
|
|
* @param string $text HTML to extract the description from.
|
|
* @return ?string Plain text, or null if no description could have been generated
|
|
*/
|
|
public function derive( string $text ): ?string;
|
|
}
|