Topic on Extension talk:TextExtracts/Flow

Return value of template parameter as summary

6
Summary by Jonathan3

No need - it uses parsed wikitext (i.e. HTML of page) - just needed to fix $ExtractsRemoveClasses to get it all to work for my pages.

Jonathan3 (talkcontribs)

How would I go about this? Most pages on my site are created from template calls (using Extension:Cargo) without any other text or headings. So no summary is extracted.

I see that it's possible to create a new API but to be able to do that I'd mostly need to copy an existing one :-)

Thiemo Kreuz (WMDE) (talkcontribs)

Is this about Popups, or about other usages of the TextExtracts API? It might be possible to customize the existing TextExtracts code so it supports your use-case better. Unfortunately, staff (like me) is probably not able to give a lot of support for customizations like this. If you are able to submit patches that make the TextExtracts extension work better with other extensions like Cargo, making it better for everyone, we can have a look at these patches.

Jonathan3 (talkcontribs)

Thanks again. It's about TextExtracts, which Popups on my site would use (I understand that WMF sites use something else). Cargo is only part of the background information, as my reason for having template-only pages (though it may be that most Cargo websites use it for infoboxes after introductory text, so mine may be a minority interest). If I can work it out I'll submit patches!

Jonathan3 (talkcontribs)

It turned out to be fairly easy. It works fine for me now after I got rid of "div" within "ExtractsRemoveClasses" in TextExtracts's extension.json file. Is there any way of making that change in LocalSettings.php instead?

(Initially I had wrongly assumed the extension looked at the raw wikitext but once I saw it used api.php?action=parse it became clearer...)

Thiemo Kreuz (WMDE) (talkcontribs)

No easy way, but it's possible:

$wgHooks['MediaWikiServices'][] = function () {
   global $wgExtractsRemoveClasses;
   $wgExtractsRemoveClasses = array_diff( $wgExtractsRemoveClasses, [ 'div' ] );
};
Jonathan3 (talkcontribs)

That seems to work - thanks!