Topic on Extension talk:SyntaxHighlightPages

Jump to navigation Jump to search
Nicole Sharp (talkcontribs)

There are no examples given of how to add file extensions. Is this the correct syntax?

$wgSyntaxHighlightPagesSuffixes = array('txt', 'htm', 'html', 'css', 'xml', 'js', 'php', 'htaccess', 'ma');

Nicole Sharp (talk) 17:07, 14 March 2021 (UTC)

Nicole Sharp (talkcontribs)

SyntaxHighlight of .htm files does not seem to work (though .html does). Did I add the .htm extension incorrectly? Nicole Sharp (talk) 19:49, 14 March 2021 (UTC)

Nicole Sharp (talkcontribs)

I tried using '.htm' instead of 'htm' but that does not appear to work either. Nicole Sharp (talk) 19:52, 14 March 2021 (UTC)

Nicole Sharp (talkcontribs)

SyntaxHighlightPages does recognize the .htm pagename though and automatically applies the syntaxhighlight content model. It just does not display the SyntaxHighlight formatting for the HTML content like it does with the .html pagename. So looks like a bug maybe if it is recognizing the pagename as a valid filetype, but not colorizing the page with HTML SyntaxHighlight. Nicole Sharp (talk) 19:58, 14 March 2021 (UTC)

Gittenburg (talkcontribs)

Hi, thanks for this report.

This extension uses Extension:SyntaxHighlight which in turn uses the Python Pygments library. While the Pygments library does have a get_lexer_for_filename function that correctly returns the HTML lexer for the html extension, the Extension:SyntaxHighlight does not provide a PHP wrapper around that method, because it doesn't need it ... which is of course unfortunate for this extension.

I'll update the page to add an example and explain this pitfall. I however don't have the time to work on a PHP wrapper for Extension:SyntaxHighlight, so as long as there is none this problem will persist for this extension.