MediaWiki Extension SyntaxHighlight: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(9 intermediate revisions by the same user not shown)
Line 34: Line 34:


=Configuration=
=Configuration=
==SELinux==
<syntaxhighlight lang='bash'>
semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/mediawiki-1.39.6/extensions/SyntaxHighlight_GeSHi/pygments(/.*)?'
restorecon -R -v /var/www/mediawiki-1.39.6/extensions/SyntaxHighlight_GeSHi/pygments/
</syntaxhighlight>
==Reduce Font Size==
==Reduce Font Size==
Look up page [[Media_Wiki_Concepts#MediaWiki:Common.css|MediaWiki:Common.css]], or create if it does not exist, and append the following sequence:
Look up page [[Media_Wiki_Concepts#MediaWiki:Common.css|MediaWiki:Common.css]], or create if it does not exist, and append the following sequence:
<syntaxhighlight lang='css'>
<syntaxhighlight lang='css'>
Line 43: Line 47:
}
}
</syntaxhighlight>
</syntaxhighlight>
=Troubleshooting=
=Troubleshooting=
While installing SyntaxHighlight on a particular MediaWiki instance, "Category: Pages with syntax highlighting errors" kept showing up and the extension did not seem to work.  
⚠️ While installing SyntaxHighlight on a particular MediaWiki instance, "Category: Pages with syntax highlighting errors" kept showing up and the extension did not seem to work.  


The issue seemed to be related to SELinux configuration and went away after executing one of the following (more research required):
The issue seemed to be related to SELinux configuration and went away after executing one of the following (more research required):
Line 56: Line 61:
</syntaxhighlight>
</syntaxhighlight>
Also see for further research: {{External|https://www.mediawiki.org/wiki/SELinux#Pygments_for_SyntaxHighlight}}
Also see for further research: {{External|https://www.mediawiki.org/wiki/SELinux#Pygments_for_SyntaxHighlight}}
⚠️ There was another time when I had to re-install the SyntaxHighlight extension from the latest downloaded version and the problem went away.
⚠️ 12/31/2023 - second time after this happened, had to reinstall from scratch, and the error went away (no activity in <code>tail -f /var/log/audit/audit.log</code>)
=Pages with Syntaxhighlight Errors=
The page is not created yet, but it collects all other pages with syntax highlight errors.
[[Category:Pages_with_syntax_highlighting_errors]]

Latest revision as of 02:37, 1 January 2024

External

Internal

Installation

Download from https://www.mediawiki.org/wiki/Special:ExtensionDistributor/SyntaxHighlight_GeSHi

Expand in /var/www/<mediawiki-dir>/extensions:

tar -xzf SyntaxHighlight_GeSHi-REL1_35-6bd7a93.tar.gz -C /var/www/mediawiki-1.35.0/extensions

Add the following line at the bottom of LocalSettings.php

wfLoadExtension( 'SyntaxHighlight_GeSHi' );

Set execute permissions for the pygmentize binary:

chmod a+x /var/www/<mediawiki-dir>/extensions/SyntaxHighlight_GeSHi/pygments/pygmentize

⚠️ Install Python 3 (python3 must be available in PATH):

Python Installation

Restart httpd:

systemctl restart httpd

Installation Verification

Navigate to Special pages → Version and ensure the extension was installed.

Configuration

SELinux

semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/mediawiki-1.39.6/extensions/SyntaxHighlight_GeSHi/pygments(/.*)?'
restorecon -R -v /var/www/mediawiki-1.39.6/extensions/SyntaxHighlight_GeSHi/pygments/

Reduce Font Size

Look up page MediaWiki:Common.css, or create if it does not exist, and append the following sequence:

/* CSS placed here will be applied to all skins */
.mw-highlight pre {
	font-size: 90%;
}

Troubleshooting

⚠️ While installing SyntaxHighlight on a particular MediaWiki instance, "Category: Pages with syntax highlighting errors" kept showing up and the extension did not seem to work.

The issue seemed to be related to SELinux configuration and went away after executing one of the following (more research required):

semanage permissive -a httpd_t # disable SELinux for httpd only

or:

semanage fcontext -a -t httpd_sys_script_exec_t '/var/www/mediawiki-1.35.0/extensions/SyntaxHighlight_GeSHi/pygments(/.*)?'
restorecon -R -v /var/www/mediawiki-1.35.0/extensions/SyntaxHighlight_GeSHi/pygments

Also see for further research:

https://www.mediawiki.org/wiki/SELinux#Pygments_for_SyntaxHighlight

⚠️ There was another time when I had to re-install the SyntaxHighlight extension from the latest downloaded version and the problem went away. ⚠️ 12/31/2023 - second time after this happened, had to reinstall from scratch, and the error went away (no activity in tail -f /var/log/audit/audit.log)

Pages with Syntaxhighlight Errors

The page is not created yet, but it collects all other pages with syntax highlight errors.