nicolas01 / highlightjs_integration Goto Github PK
View Code? Open in Web Editor NEWA MediaWiki extension to use the client-side syntax highlighter highlight.js
License: GNU Affero General Public License v3.0
A MediaWiki extension to use the client-side syntax highlighter highlight.js
License: GNU Affero General Public License v3.0
Trying to run with MediaWiki 1.35.3 in XAMPP (Windows 10), however extension files cannot be loaded, seems the path part extensions\Highlightjs_Integration
is omitted(?).
Is there anything I can adjust?
Apache error.log:
[Thu Mar 16 12:10:53.189761 2023] [php:warn] [pid 10668:tid 1916] [client ::1:56357] PHP Warning: md5_file(C:\\xampp\\htdocs\\wiki/highlight/highlight.min.js): Failed to open stream: No such file or directory in C:\\xampp\\htdocs\\wiki\\includes\\OutputPage.php on line 3993, referer: http://localhost/wiki/Template:Code_block?debug=true
[Thu Mar 16 12:10:53.189761 2023] [php:warn] [pid 10668:tid 1916] [client ::1:56357] PHP Warning: OutputPage::transformFilePath: Failed to hash C:\\xampp\\htdocs\\wiki/highlight/highlight.min.js [Called from OutputPage::transformFilePath in C:\\xampp\\htdocs\\wiki\\includes\\OutputPage.php at line 3995] in C:\\xampp\\htdocs\\wiki\\includes\\debug\\MWDebug.php on line 430, referer: http://localhost/wiki/Template:Code_block?debug=true
[Thu Mar 16 12:10:53.190758 2023] [php:warn] [pid 10668:tid 1916] [client ::1:56357] PHP Warning: md5_file(C:\\xampp\\htdocs\\wiki/init.js): Failed to open stream: No such file or directory in C:\\xampp\\htdocs\\wiki\\includes\\OutputPage.php on line 3993, referer: http://localhost/wiki/Template:Code_block?debug=true
[Thu Mar 16 12:10:53.190758 2023] [php:warn] [pid 10668:tid 1916] [client ::1:56357] PHP Warning: OutputPage::transformFilePath: Failed to hash C:\\xampp\\htdocs\\wiki/init.js [Called from OutputPage::transformFilePath in C:\\xampp\\htdocs\\wiki\\includes\\OutputPage.php at line 3995] in C:\\xampp\\htdocs\\wiki\\includes\\debug\\MWDebug.php on line 430, referer: http://localhost/wiki/Template:Code_block?debug=true
[Thu Mar 16 12:10:53.192769 2023] [php:warn] [pid 10668:tid 1916] [client ::1:56357] PHP Warning: md5_file(C:\\xampp\\htdocs\\wiki/custom.css): Failed to open stream: No such file or directory in C:\\xampp\\htdocs\\wiki\\includes\\OutputPage.php on line 3993, referer: http://localhost/wiki/Template:Code_block?debug=true
[Thu Mar 16 12:10:53.192769 2023] [php:warn] [pid 10668:tid 1916] [client ::1:56357] PHP Warning: OutputPage::transformFilePath: Failed to hash C:\\xampp\\htdocs\\wiki/custom.css [Called from OutputPage::transformFilePath in C:\\xampp\\htdocs\\wiki\\includes\\OutputPage.php at line 3995] in C:\\xampp\\htdocs\\wiki\\includes\\debug\\MWDebug.php on line 430, referer: http://localhost/wiki/Template:Code_block?debug=true
[Thu Mar 16 12:10:53.192769 2023] [php:warn] [pid 10668:tid 1916] [client ::1:56357] PHP Warning: md5_file(C:\\xampp\\htdocs\\wiki/highlight/styles/vs2015.min.css): Failed to open stream: No such file or directory in C:\\xampp\\htdocs\\wiki\\includes\\OutputPage.php on line 3993, referer: http://localhost/wiki/Template:Code_block?debug=true
[Thu Mar 16 12:10:53.192769 2023] [php:warn] [pid 10668:tid 1916] [client ::1:56357] PHP Warning: OutputPage::transformFilePath: Failed to hash C:\\xampp\\htdocs\\wiki/highlight/styles/vs2015.min.css [Called from OutputPage::transformFilePath in C:\\xampp\\htdocs\\wiki\\includes\\OutputPage.php at line 3995] in C:\\xampp\\htdocs\\wiki\\includes\\debug\\MWDebug.php on line 430, referer: http://localhost/wiki/Template:Code_block?debug=true
On a page where I use SyntaxHighlight, once I click submit, I get a huge page with warnings, foremost:
Deprecated: Use of Sanitizer::validateAttributes with sequential array was deprecated in MediaWiki 1.35. [Called from HighlightjsIntegration::renderSyntaxhighlight in C:\wamp\www\wiki\extensions\Highlightjs_Integration-master\HighlightjsIntegration.class.php at line 42] in C:\wamp\www\wiki\includes\debug\MWDebug.php on line 381
I'm using Mediawiki 1.39.1 (lastest) with latest version of Highlightjs_Integration.
Hello,
Does this extension support line numbers ?
The SyntaxHighlight extension allows for using the style
attribute, but this extension ends up stripping that. This prevents this extension from being a drop-in replacement for the SyntaxHighlight extension.
Hello,
Is it possible to add the tag that is on the right top corner of the highlight window as we can see on the demo site https://highlightjs.org/ to see what type of script is it ?
Thanks
When I try to edit a page using VisualEditor, nothing is shown in the code lines. Is there a way to make it work in VisualEditor like SyntaxHighlight_GeSHi does?
I'm using version 1.2 in xampp with MediaWiki 1.31.1, PHP 7.0.33.
Nice extension!
I just wanted to let you know that I could only download the source code from Github.
The download link on your extention page points to https://www.mediawiki.org/wiki/Special:ExtensionDistributor/Highlightjs_Integration/HighlightjsIntegration, which doesn't appear to work.
Let me know if I can help as well,
Thanks!
When I have a block of code that has leading spaces, the leading spaces from the first line get removed, which throws off the alignment for other lines in the block. The SyntaxHighlight extension does not have this issue and leading spaces are correctly preserved.
Mediawiiki 1.35.13 from Debian 11 with this extension v2.2 (bundled highlight.min.js) throws JS error on browser console
Uncaught SyntaxError: Invalid regular expression: missing /
Maybe this is still not resolved?
Hello,
With the default stuff in the init.js nor the suggested code below worked to highlight the commone pages of mediawiki like common.css and common.js
`hljs.configure({
cssSelector: 'pre.code2highlight, code.code2highlight, pre.mwcode'
});
hljs.highlightAll();`
The only one worked is this one from the syntaxhighlighJS v1.2
$(document).ready(function() { $('pre.code2highlight, code.code2highlight, pre.mw-code').each(function(i, block) { hljs.highlightBlock(block); }); });
The SyntaxHighlight MediaWiki extension (which this extension aims to provide an alternative to) supports the line
parameter (with optional start
parameter) for adding line numbers and the highlight
parameter for emphasizing specific lines. It seems that base highlight.js does not allow these, but from a few quick Google searches, it appears that there are two plugins that add support and work together:
When using this extension and attempting to use within a numbered list and more than one line of code, like such:
# Step1
# Step 2 has some code: <SyntaxHighlight lang="bash">
Totally
some
bash lines
here
</SyntaxHighlight>
# Step 3
the output is butchered:
It appears that there is a need to strip code if a parser is used. I was able to modify the code using some slightly edited code from the native SyntaxHighlight_GeSHi module to fix this:
if ($inline) {
$htmlAttribs['style'] = 'display: inline;';
$out = Html::rawElement('code', $htmlAttribs, $code);
return $out;
} else {
if ( $parser ) {
// Use 'nowiki' strip marker to prevent list processing (also known as doBlockLevels()).
// However, leave the wrapping <div/> outside to prevent <p/>-wrapping.
$marker = $parser::MARKER_PREFIX . '-syntaxhighlightinner-' .
sprintf( '%08X', $parser->mMarkerIndex++ ) . $parser::MARKER_SUFFIX;
$parser->getStripState()->addNoWiki( $marker, $code );
$code = $marker;
}
$out = Html::rawElement('pre', $htmlAttribs, $code);
return $out;
}
Modifying the code as shown would then properly box in all the code in the numbered list and keep the list numbering intact.
Also, note really a bug or related, but more as a easy migration from the builtin tooling to this extension (since it doesn't work on Windows and this does), I also added the following to catch (enclose="none"):
$inline = isset($param['inline']);
if ($param['enclose'] == 'none') {
$inline = true;
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.