X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcontent%2FWikiTextStructure.php;h=1128d7bd36ed06f5a2e3411d5650cfb998152a5d;hb=9935b156211812c3800318fe1c7fe3dfb4c47b24;hp=fe12ff735e68870a804ebd4154fa77206f77275d;hpb=7da0949b385c30468aed1b6cb8140dc25727a826;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/content/WikiTextStructure.php b/includes/content/WikiTextStructure.php index fe12ff735e..1128d7bd36 100644 --- a/includes/content/WikiTextStructure.php +++ b/includes/content/WikiTextStructure.php @@ -27,30 +27,40 @@ class WikiTextStructure { * @var string[] selectors to elements that are excluded entirely from search */ private $excludedElementSelectors = [ - 'audio', 'video', // "it looks like you don't have javascript enabled..." - // do not need to index - 'sup.reference', // The [1] for references - '.mw-cite-backlink', // The ↑ next to references in the references section - 'h1', 'h2', 'h3', // Headings are already indexed in their own field. - 'h5', 'h6', 'h4', - '.autocollapse', // Collapsed fields are hidden by default so we don't want them - // showing up. + // "it looks like you don't have javascript enabled..." – do not need to index + 'audio', 'video', + // CSS stylesheets aren't content + 'style', + // The [1] for references + 'sup.reference', + // The ↑ next to references in the references section + '.mw-cite-backlink', + // Headings are already indexed in their own field. + 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', + // Collapsed fields are hidden by default so we don't want them showing up. + '.autocollapse', + // Content explicitly decided to be not searchable by editors such + // as custom navigation templates. + '.navigation-not-searchable' ]; /** * @var string[] selectors to elements that are considered auxiliary to article text for search */ private $auxiliaryElementSelectors = [ - '.thumbcaption', // Thumbnail captions aren't really part of the text proper - 'table', // Neither are tables - '.rellink', // Common style for "See also:". - '.dablink', // Common style for calling out helpful links at the top - // of the article. - '.searchaux', // New class users can use to mark stuff as auxiliary to searches. + // Thumbnail captions aren't really part of the text proper + '.thumbcaption', + // Neither are tables + 'table', + // Common style for "See also:". + '.rellink', + // Common style for calling out helpful links at the top of the article. + '.dablink', + // New class users can use to mark stuff as auxiliary to searches. + '.searchaux', ]; /** - * WikiTextStructure constructor. * @param ParserOutput $parserOutput */ public function __construct( ParserOutput $parserOutput ) { @@ -77,7 +87,7 @@ class WikiTextStructure { $heading = $heading[ 'line' ]; // Some wikis wrap the brackets in a span: - // http://en.wikipedia.org/wiki/MediaWiki:Cite_reference_link + // https://en.wikipedia.org/wiki/MediaWiki:Cite_reference_link $heading = preg_replace( '/<\/?span>/', '', $heading ); // Normalize [] so the following regexp would work. $heading = preg_replace( [ '/[/', '/]/' ], [ '[', ']' ], $heading ); @@ -138,9 +148,10 @@ class WikiTextStructure { if ( !is_null( $this->allText ) ) { return; } - $this->parserOutput->setEditSectionTokens( false ); - $this->parserOutput->setTOCEnabled( false ); - $text = $this->parserOutput->getText(); + $text = $this->parserOutput->getText( [ + 'enableSectionEditTokens' => false, + 'allowTOC' => false, + ] ); if ( strlen( $text ) == 0 ) { $this->allText = ""; // empty text - nothing to seek here