Compare commits
No commits in common. "main" and "prism-misc" have entirely different histories.
main
...
prism-misc
8 changed files with 53 additions and 85 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,4 +0,0 @@
|
|||
makerelease.sh
|
||||
mirror.sh
|
||||
syntaxhighlighter/
|
||||
syntaxhighlighter-*.zip
|
28
README.md
28
README.md
|
@ -4,9 +4,6 @@ Origin: https://git.la10cy.net/DeltaLima/flatpress-plugin-syntaxhighlighter-ng
|
|||
|
||||
Demo: https://deltalima.org/blog/index.php/syntaxhighlighter-ng-testpage/
|
||||
|
||||
# THIS PLUGIN GETS NOW MAINTAINED IN https://github.com/flatpressblog/flatpress-extras
|
||||
# PLEASE LOOK THERE FOR THE LATEST VERSION
|
||||
|
||||
based on the original FlatPress plugin [syntaxhighlighter from 2005](https://forum.flatpress.org/viewtopic.php?p=1130&hilit=syntax+highlight#p1135), updated in 2023 to prism.js
|
||||
|
||||
## installation
|
||||
|
@ -48,27 +45,24 @@ The default values are `small` for size (see available languages below) and `oka
|
|||
/*
|
||||
* size: tiny, small, full
|
||||
*
|
||||
* 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: 106KB (markup, css, clike, javascript, apacheconf, arduino, bash, basic, batch,
|
||||
* bbcode, c, cpp, cmake, csv, diff, docker, git, go, http, ini, java, json,
|
||||
* log, makefile, markdown, markup-templating, nginx, pascal, perl, php,
|
||||
* powershell, python, ruby, shell-session, sql, typescript, vbnet,
|
||||
* visual-basic, wiki, yaml)
|
||||
* small: 95KB (Markup, HTML, XML,SVG, MathML, SSML, Atom, RSS, CSS, C-Linke, JavaScript
|
||||
* Apache, Bash, Batch, BBCode, C, C#, C++, CSV, Diff, Go, HTTP, ini, Java
|
||||
* JSON, Makefile, Markdown, nginx, Perl, PHP, PowerShell, Python, Ruby
|
||||
* Shell session, SQL, VB.Net, Wiki markup, YML)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* line-numbers: 'true' or 'false' (Do show line numbers or not)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
return [
|
||||
// change here
|
||||
'size' => 'small',
|
||||
'theme' => 'okaidia',
|
||||
'line-numbers' => 'true',
|
||||
// change here
|
||||
'size' => 'small',
|
||||
'theme' => 'okaidia',
|
||||
]
|
||||
?>
|
||||
```
|
||||
|
||||
|
|
24
config.php
24
config.php
|
@ -2,26 +2,22 @@
|
|||
/*
|
||||
* size: tiny, small, full
|
||||
*
|
||||
* 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: 106KB (markup, css, clike, javascript, apacheconf, arduino, bash, basic, batch,
|
||||
* bbcode, c, cpp, cmake, csv, diff, docker, git, go, http, ini, java, json,
|
||||
* log, makefile, markdown, markup-templating, nginx, pascal, perl, php,
|
||||
* powershell, python, ruby, shell-session, sql, typescript, vbnet,
|
||||
* visual-basic, wiki, yaml)
|
||||
* small: 95KB (Markup, HTML, XML,SVG, MathML, SSML, Atom, RSS, CSS, C-Linke, JavaScript
|
||||
* Apache, Bash, Batch, BBCode, C, C#, C++, CSV, Diff, Go, HTTP, ini, Java
|
||||
* JSON, Makefile, Markdown, nginx, Perl, PHP, PowerShell, Python, Ruby
|
||||
* Shell session, SQL, VB.Net, Wiki markup, YML)
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* line-numbers: 'true' or 'false' (Do show line numbers or not)
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
return [
|
||||
// change here
|
||||
'size' => 'small',
|
||||
'theme' => 'okaidia',
|
||||
'line-numbers' => 'true',
|
||||
// change here
|
||||
'size' => 'small',
|
||||
'theme' => 'okaidia',
|
||||
]
|
||||
?>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: SyntaxHighlighter-NG
|
||||
Version: 1.0.3
|
||||
Version: 1.0.1
|
||||
Plugin URI: https://git.la10cy.net/DeltaLima/flatpress-plugin-syntaxhighlighter-ng
|
||||
Description: <a href="https://git.la10cy.net/DeltaLima/flatpress-plugin-syntaxhighlighter-ng/">SyntaxHighlighter-NG</a> (forked from <a href="https://forum.flatpress.org/viewtopic.php?p=1130&hilit=syntax+highlight#p1135">Arvid's forum post</a>, using now <a href="https://prismjs.com">prism.js</a>)
|
||||
Author: 2005 NoWhereMan, 2023 DeltaLima
|
||||
|
@ -34,12 +34,13 @@ function plugin_syntaxhighlighter_add($lang=null) {
|
|||
|
||||
$pdir=plugin_geturl('syntaxhighlighter');
|
||||
|
||||
// create array containing the used languages
|
||||
// create array containing the used languages
|
||||
$languages[] = "{$lang}";
|
||||
// remove unique
|
||||
// remove unique
|
||||
$languages = array_unique($languages);
|
||||
|
||||
return $languages;
|
||||
return $languages;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,8 +51,7 @@ function plugin_syntaxhighlighter_head() {
|
|||
echo <<<PRISMJS
|
||||
<!-- 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 -->
|
||||
PRISMJS;
|
||||
|
@ -63,29 +63,27 @@ add_action('wp_head', 'plugin_syntaxhighlighter_head');
|
|||
|
||||
function plugin_syntaxhighlighter_foot() {
|
||||
|
||||
$config = include('config.php');
|
||||
// convert the returned array into a json one, to have an easier time
|
||||
// giving it to the javascript below
|
||||
$used_languages = json_encode(plugin_syntaxhighlighter_add());
|
||||
$config = include('config.php');
|
||||
// convert the returned array into a json one, to have an easier time
|
||||
// giving it to the javascript below
|
||||
$used_languages = json_encode(plugin_syntaxhighlighter_add());
|
||||
|
||||
$pdir=plugin_geturl('syntaxhighlighter');
|
||||
// javascript part
|
||||
echo <<<PRISMBOX
|
||||
<!-- start of prism.js footer -->
|
||||
|
||||
<script type="text/javascript" src="{$pdir}res/prism.{$config['size']}.js"></script>
|
||||
|
||||
<!-- include wrapping-function to wrap content of pre html-tags into code-tags, as said in https://prismjs.com/index.html#basic-usage -->
|
||||
<script type="text/javascript" src="{$pdir}res/syntaxhighlighter-ng.js"></script>
|
||||
|
||||
<!-- call wrap_pre_tags() from syntaxhighlighter-ng.js -->
|
||||
<script type="text/javascript">
|
||||
var used_languages = {$used_languages};
|
||||
wrap_pre_tags(used_languages);
|
||||
</script>
|
||||
|
||||
$pdir=plugin_geturl('syntaxhighlighter');
|
||||
// javascript part
|
||||
|
||||
echo <<<PRISMBOX
|
||||
<!-- start of prism.js footer -->
|
||||
|
||||
<script type="text/javascript" src="{$pdir}res/prism.{$config['size']}.js"></script>
|
||||
|
||||
<!-- include wrapping-function to wrap content of pre html-tags into code-tags, as said in https://prismjs.com/index.html#basic-usage -->
|
||||
<script type="text/javascript" src="{$pdir}res/syntaxhighlighter-ng.js"></script>
|
||||
|
||||
<!-- call wrap_pre_tags() from syntaxhighlighter-ng.js -->
|
||||
<script type="text/javascript">
|
||||
var used_languages = {$used_languages};
|
||||
var enable_line_numbers = {$config['line-numbers']};
|
||||
wrap_pre_tags(used_languages, enable_line_numbers);
|
||||
</script>
|
||||
|
||||
<!-- end of prism.js footer -->
|
||||
PRISMBOX;
|
||||
}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
/* 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
|
@ -24,14 +24,7 @@
|
|||
|
||||
|
||||
|
||||
function wrap_pre_tags(used_languages, enable_line_numbers) {
|
||||
|
||||
if ( enable_line_numbers == true )
|
||||
{
|
||||
enable_line_numbers = "line-numbers";
|
||||
} else {
|
||||
enable_line_numbers = "";
|
||||
}
|
||||
function wrap_pre_tags(used_languages) {
|
||||
// iterate through all used_languages
|
||||
for (let iUl = 0;iUl < used_languages.length; iUl++)
|
||||
{
|
||||
|
@ -51,9 +44,9 @@ function wrap_pre_tags(used_languages, enable_line_numbers) {
|
|||
{
|
||||
// put the content of <pre> tag into org_html
|
||||
org_html = preElements[iEl].innerHTML;
|
||||
// put <code> tag with 'language-' class and plugin-classes
|
||||
// put <code> tag with 'language-' class and class for 'line-numbers'
|
||||
// prism.js plugin around the <pre> content
|
||||
new_html = "<code class=\"language-" + used_languages[iUl] + " " + enable_line_numbers + "\">" + org_html + "</code>";
|
||||
new_html = "<code class=\"line-numbers language-" + used_languages[iUl] + "\">" + org_html + "</code>";
|
||||
// write back our new html and enjoy syntax highlightning :)
|
||||
preElements[iEl].innerHTML = new_html;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue