Compare commits

...

8 commits

8 changed files with 81 additions and 52 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
makerelease.sh
mirror.sh
syntaxhighlighter/
syntaxhighlighter-*.zip

View file

@ -47,22 +47,25 @@ The default values are `small` for size (see available languages below) and `oka
* *
* tiny: 21KB (Markup, HTML, XML, SVG, MathML, SSML, Atom, RSS, CSS, C-like, JavaScript) * tiny: 21KB (Markup, HTML, XML, SVG, MathML, SSML, Atom, RSS, CSS, C-like, JavaScript)
* *
* small: 95KB (Markup, HTML, XML,SVG, MathML, SSML, Atom, RSS, CSS, C-Linke, JavaScript * small: 95KB (markup, css, clike, javascript, apacheconf, arduino, bash, basic, batch,
* Apache, Bash, Batch, BBCode, C, C#, C++, CSV, Diff, Go, HTTP, ini, Java * bbcode, c, cpp, cmake, csv, diff, docker, git, go, http, ini, java, json,
* JSON, Makefile, Markdown, nginx, Perl, PHP, PowerShell, Python, Ruby * log, makefile, markdown, markup-templating, nginx, pascal, perl, php,
* Shell session, SQL, VB.Net, Wiki markup, YML) * powershell, python, ruby, shell-session, sql, typescript, vbnet,
* visual-basic, wiki, yaml)
* *
* full: 567KB (see https://prismjs.com/index.html#supported-languages for list of supported languages) * full: 567KB (see https://prismjs.com/index.html#supported-languages for list of supported languages)
* *
* theme: coy, dark, default, funky, okaidia, solarizedlight, tomorrow, twilight * theme: coy, dark, default, funky, okaidia, solarizedlight, tomorrow, twilight
* *
* line-numbers: 'true' or 'false' (Do show line numbers or not)
*
*/ */
return [ return [
// change here // change here
'size' => 'small', 'size' => 'small',
'theme' => 'okaidia', 'theme' => 'okaidia',
'line-numbers' => 'true',
] ]
?> ?>
``` ```

View file

@ -4,20 +4,24 @@
* *
* tiny: 21KB (Markup, HTML, XML, SVG, MathML, SSML, Atom, RSS, CSS, C-like, JavaScript) * tiny: 21KB (Markup, HTML, XML, SVG, MathML, SSML, Atom, RSS, CSS, C-like, JavaScript)
* *
* small: 95KB (Markup, HTML, XML,SVG, MathML, SSML, Atom, RSS, CSS, C-Linke, JavaScript * small: 95KB (markup, css, clike, javascript, apacheconf, arduino, bash, basic, batch,
* Apache, Bash, Batch, BBCode, C, C#, C++, CSV, Diff, Go, HTTP, ini, Java * bbcode, c, cpp, cmake, csv, diff, docker, git, go, http, ini, java, json,
* JSON, Makefile, Markdown, nginx, Perl, PHP, PowerShell, Python, Ruby * log, makefile, markdown, markup-templating, nginx, pascal, perl, php,
* Shell session, SQL, VB.Net, Wiki markup, YML) * powershell, python, ruby, shell-session, sql, typescript, vbnet,
* visual-basic, wiki, yaml)
* *
* full: 567KB (see https://prismjs.com/index.html#supported-languages for list of supported languages) * full: 567KB (see https://prismjs.com/index.html#supported-languages for list of supported languages)
* *
* theme: coy, dark, default, funky, okaidia, solarizedlight, tomorrow, twilight * theme: coy, dark, default, funky, okaidia, solarizedlight, tomorrow, twilight
* *
* line-numbers: 'true' or 'false' (Do show line numbers or not)
*
*/ */
return [ return [
// change here // change here
'size' => 'small', 'size' => 'small',
'theme' => 'okaidia', 'theme' => 'okaidia',
'line-numbers' => 'true',
] ]
?> ?>

View file

@ -40,7 +40,6 @@ function plugin_syntaxhighlighter_add($lang=null) {
$languages = array_unique($languages); $languages = array_unique($languages);
return $languages; return $languages;
} }
@ -51,6 +50,7 @@ function plugin_syntaxhighlighter_head() {
echo <<<PRISMJS echo <<<PRISMJS
<!-- start of prism.js header --> <!-- start of prism.js header -->
<link rel="stylesheet" type="text/css" href="{$pdir}res/prism.plugins.css" />
<link rel="stylesheet" type="text/css" href="{$pdir}res/prism-{$config['theme']}.css" /> <link rel="stylesheet" type="text/css" href="{$pdir}res/prism-{$config['theme']}.css" />
<!-- end of prism.js header --> <!-- end of prism.js header -->
@ -70,7 +70,8 @@ function plugin_syntaxhighlighter_foot() {
$pdir=plugin_geturl('syntaxhighlighter'); $pdir=plugin_geturl('syntaxhighlighter');
// javascript part // javascript part
echo <<<PRISMBOX
echo <<<PRISMBOX
<!-- start of prism.js footer --> <!-- start of prism.js footer -->
<script type="text/javascript" src="{$pdir}res/prism.{$config['size']}.js"></script> <script type="text/javascript" src="{$pdir}res/prism.{$config['size']}.js"></script>
@ -81,7 +82,8 @@ function plugin_syntaxhighlighter_foot() {
<!-- call wrap_pre_tags() from syntaxhighlighter-ng.js --> <!-- call wrap_pre_tags() from syntaxhighlighter-ng.js -->
<script type="text/javascript"> <script type="text/javascript">
var used_languages = {$used_languages}; var used_languages = {$used_languages};
wrap_pre_tags(used_languages); var enable_line_numbers = {$config['line-numbers']};
wrap_pre_tags(used_languages, enable_line_numbers);
</script> </script>
<!-- end of prism.js footer --> <!-- end of prism.js footer -->

4
res/prism.plugins.css Normal file
View file

@ -0,0 +1,4 @@
/* unescaped-markup */
[class*=lang-] script[type='text/plain'],[class*=language-] script[type='text/plain'],script[type='text/plain'][class*=lang-],script[type='text/plain'][class*=language-]{display:block;font:100% Consolas,Monaco,monospace;white-space:pre;overflow:auto}
/* line-numbers */
pre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -24,7 +24,14 @@
function wrap_pre_tags(used_languages) { function wrap_pre_tags(used_languages, enable_line_numbers) {
if ( enable_line_numbers == true )
{
enable_line_numbers = "line-numbers";
} else {
enable_line_numbers = "";
}
// iterate through all used_languages // iterate through all used_languages
for (let iUl = 0;iUl < used_languages.length; iUl++) for (let iUl = 0;iUl < used_languages.length; iUl++)
{ {
@ -44,9 +51,9 @@ function wrap_pre_tags(used_languages) {
{ {
// put the content of <pre> tag into org_html // put the content of <pre> tag into org_html
org_html = preElements[iEl].innerHTML; org_html = preElements[iEl].innerHTML;
// put <code> tag with 'language-' class and class for 'line-numbers' // put <code> tag with 'language-' class and plugin-classes
// prism.js plugin around the <pre> content // prism.js plugin around the <pre> content
new_html = "<code class=\"line-numbers language-" + used_languages[iUl] + "\">" + org_html + "</code>"; new_html = "<code class=\"language-" + used_languages[iUl] + " " + enable_line_numbers + "\">" + org_html + "</code>";
// write back our new html and enjoy syntax highlightning :) // write back our new html and enjoy syntax highlightning :)
preElements[iEl].innerHTML = new_html; preElements[iEl].innerHTML = new_html;
} }