commit 745b074df881c76e2674b3c0ff6b3cae21814863 Author: DeltaLima Date: Tue Jun 20 23:18:53 2023 +0200 first commit, heavely WIP at this point diff --git a/README.md b/README.md new file mode 100644 index 0000000..89692ad --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +syntaxhighlighter-ng based on the original fp-plugin from 2005, updated to 2023 with prism.js diff --git a/plugin.syntaxhighlighter.php b/plugin.syntaxhighlighter.php new file mode 100644 index 0000000..dbcc70b --- /dev/null +++ b/plugin.syntaxhighlighter.php @@ -0,0 +1,137 @@ +dp.SyntaxHighlighter 1.4.0 (edited to work with pre, thanks to Gert Thiel ) +Author: NoWhereMan +Author URI: http://flatpress.sf.net +*/ + + +function plugin_syntaxhighlighter_add($lang=null) { + static $languages = array(); + + $pdir=plugin_geturl('syntaxhighlighter'); + + //if ($lang) { + //~ switch ($lang) { + //~ case 'c': + //~ case 'cpp': + //~ case 'c++': + //~ $scripts[] = "\n"; break; + //~ case 'css': + //~ $scripts[] = "\n"; break; + //~ case 'c#': + //~ case 'c-sharp': + //~ case 'csharp': + //~ $scripts[] = "\n"; break; + //~ case 'vb': + //~ case 'vb.net': + //~ $scripts[] = "\n"; break; + //~ case 'delphi': + //~ case 'pascal': + //~ $scripts[] = "\n"; break; + + //~ case 'js': + //~ case 'jscript': + //~ case 'javascript': + //~ $scripts[] = "\n"; break; + //~ case 'php': + //~ $scripts[] = "\n"; break; + //~ case 'py': + //~ case 'python': + //~ $scripts[] = "\n"; break; + //~ case 'ruby': + //~ $scripts[] = "\n"; break; + //~ case 'sql': + //~ $scripts[] = "\n"; break; + //~ case 'xml': + //~ case 'xhtml': + //~ case 'xslt': + //~ case 'html': + //~ case 'xhtml': + //~ "\n"; + + //~ } + $languages[] = "{$lang}"; + $languages = array_unique($languages); + + //} + //return $scripts; + return $languages; + +} + + +function plugin_syntaxhighlighter_head() { + $pdir=plugin_geturl('syntaxhighlighter'); +echo << + + + + + +SHL; + +} +add_action('wp_head', 'plugin_syntaxhighlighter_head'); + + +function plugin_syntaxhighlighter_foot() { + + //$used_languages = implode(plugin_syntaxhighlighter_add(), "\n"); + $used_languages = json_encode(plugin_syntaxhighlighter_add()); + $pdir=plugin_geturl('syntaxhighlighter'); + echo << + + + + + + + + + + + +SHLBOX; +} +add_action('wp_footer', 'plugin_syntaxhighlighter_foot'); + + + +?> diff --git a/res/SyntaxHighlighter.css b/res/SyntaxHighlighter.css new file mode 100644 index 0000000..010b423 --- /dev/null +++ b/res/SyntaxHighlighter.css @@ -0,0 +1,240 @@ +/* Main style for the table */ + +.dp-highlighter +{ + font-family: "Courier New" , Courier, mono; + font-size: 12px; + border: 1px solid #2B91AF; + background-color: #fff; + width: 99%; + overflow: auto; + line-height: 100% !important; + margin: 18px 0px 18px 0px; +} + +/* +.dp-highlighter .bar +{ + padding-left: 45px; +} + +.dp-highlighter ol +{ + margin: 0px 0px 0px 45px; + padding: 0px; + color: #2B91AF; +} +*/ +.dp-highlighter ol li, .dp-highlighter .columns div +{ + border-left: 3px solid #6CE26C; + background-color: #fff; + padding-left: 10px; + line-height: 14px; +} + +.dp-highlighter .columns +{ + color: gray; + overflow: hidden; + width: 100%; +} + +.dp-highlighter .columns div +{ + padding-bottom: 5px; +} + +.dp-highlighter ol li.alt +{ + background-color: #e9e9e9; +} + +.dp-highlighter ol li span +{ + color: Black; +} + +/* Adjust some properties when wollapsed */ + +.dp-highlighter.collapsed ol +{ + margin: 0px; +} + +.dp-highlighter.collapsed ol li +{ + display: none; +} + +.dp-highlighter.collapsed .tools +{ + border-bottom: none; +} + +/* Additional modifications when in print-view */ + +.dp-highlighter.printing +{ + border: none; +} + +.dp-highlighter.printing .tools +{ + display: none !important; + border: 5px solid black; +} + +.dp-highlighter.printing li +{ + display: list-item !important; +} + +/* Styles for the tools */ + +.dp-highlighter .tools +{ + padding: 3px 8px 3px 10px; + border-bottom: 1px solid #2B91AF; + font: 9px Verdana, Geneva, Arial, Helvetica, sans-serif; + color: silver; +} + +.dp-highlighter .tools a +{ + font-size: 9px; + color: gray; + text-decoration: none; + margin-right: 10px; +} + +.dp-highlighter .tools a:hover +{ + color: red; + text-decoration: underline; +} + +/* About dialog styles */ + +.dp-about +{ + background-color: #fff; + margin: 0px; +} + +.dp-about table +{ + width: 100%; + height: 100%; + font-size: 11px; + font-family: Tahoma, Verdana, Arial, sans-serif !important; +} + +.dp-about td +{ + padding: 10px; + vertical-align: top; +} + +.dp-about .copy +{ + border-bottom: 1px solid #ACA899; + height: 95%; +} + +.dp-about .title +{ + color: red; + font-weight: bold; +} + +.dp-about .para +{ + margin-bottom: 4px; +} + +.dp-about .footer +{ + background-color: #ECEADB; + border-top: 1px solid #fff; + text-align: right; +} + +.dp-about .close +{ + font-size: 11px; + font-family: Tahoma, Verdana, Arial, sans-serif !important; + background-color: #ECEADB; + width: 60px; + height: 22px; +} + +/* Language specific styles */ + +.dp-c {} +.dp-c .comment { color: green; } +.dp-c .string { color: blue; } +.dp-c .preprocessor { color: gray; } +.dp-c .keyword { color: blue; } +.dp-c .vars { color: #d00; } + +.dp-vb {} +.dp-vb .comment { color: green; } +.dp-vb .string { color: blue; } +.dp-vb .preprocessor { color: gray; } +.dp-vb .keyword { color: blue; } + +.dp-sql {} +.dp-sql .comment { color: green; } +.dp-sql .string { color: red; } +.dp-sql .keyword { color: blue; } +.dp-sql .func { color: #ff1493; } +.dp-sql .op { color: #808080; } + +.dp-xml {} +.dp-xml .cdata { color: #ff1493; } +.dp-xml .comments { color: green; } +.dp-xml .tag { font-weight: bold; color: blue; } +.dp-xml .tag-name { color: black; font-weight: bold; } +.dp-xml .attribute { color: red; } +.dp-xml .attribute-value { color: blue; } + +.dp-delphi {} +.dp-delphi .comment { color: #008200; font-style: italic; } +.dp-delphi .string { color: blue; } +.dp-delphi .number { color: blue; } +.dp-delphi .directive { color: #008284; } +.dp-delphi .keyword { font-weight: bold; color: navy; } +.dp-delphi .vars { color: #000; } + +.dp-py {} +.dp-py .comment { color: green; } +.dp-py .string { color: red; } +.dp-py .docstring { color: green; } +.dp-py .keyword { color: blue; font-weight: bold;} +.dp-py .builtins { color: #ff1493; } +.dp-py .magicmethods { color: #808080; } +.dp-py .exceptions { color: brown; } +.dp-py .types { color: brown; font-style: italic; } +.dp-py .commonlibs { color: #8A2BE2; font-style: italic; } + +.dp-rb {} +.dp-rb .comment { color: #c00; } +.dp-rb .string { color: #f0c; } +.dp-rb .symbol { color: #02b902; } +.dp-rb .keyword { color: #069; } +.dp-rb .variable { color: #6cf; } + +.dp-css {} +.dp-css .comment { color: green; } +.dp-css .string { color: red; } +.dp-css .keyword { color: blue; } +.dp-css .colors { color: darkred; } +.dp-css .vars { color: #d00; } + +.dp-j {} +.dp-j .comment { color: rgb(63,127,95); } +.dp-j .string { color: rgb(42,0,255); } +.dp-j .keyword { color: rgb(127,0,85); font-weight: bold } +.dp-j .annotation { color: #646464; } +.dp-j .number { color: #C00000; } diff --git a/res/prism.css b/res/prism.css new file mode 100644 index 0000000..dfdd2c0 --- /dev/null +++ b/res/prism.css @@ -0,0 +1,126 @@ +/* PrismJS 1.29.0 +https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript */ +/** + * okaidia theme for JavaScript, CSS and HTML + * Loosely based on Monokai textmate theme by http://www.monokai.nl/ + * @author ocodia + */ + +code[class*="language-"], +pre[class*="language-"] { + color: #f8f8f2; + background: none; + text-shadow: 0 1px rgba(0, 0, 0, 0.3); + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + font-size: 1em; + text-align: left; + white-space: pre; + word-spacing: normal; + word-break: normal; + word-wrap: normal; + line-height: 1.5; + + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; + + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; +} + +/* Code blocks */ +pre[class*="language-"] { + padding: 1em; + margin: .5em 0; + overflow: auto; + border-radius: 0.3em; +} + +:not(pre) > code[class*="language-"], +pre[class*="language-"] { + background: #272822; +} + +/* Inline code */ +:not(pre) > code[class*="language-"] { + padding: .1em; + border-radius: .3em; + white-space: normal; +} + +.token.comment, +.token.prolog, +.token.doctype, +.token.cdata { + color: #8292a2; +} + +.token.punctuation { + color: #f8f8f2; +} + +.token.namespace { + opacity: .7; +} + +.token.property, +.token.tag, +.token.constant, +.token.symbol, +.token.deleted { + color: #f92672; +} + +.token.boolean, +.token.number { + color: #ae81ff; +} + +.token.selector, +.token.attr-name, +.token.string, +.token.char, +.token.builtin, +.token.inserted { + color: #a6e22e; +} + +.token.operator, +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string, +.token.variable { + color: #f8f8f2; +} + +.token.atrule, +.token.attr-value, +.token.function, +.token.class-name { + color: #e6db74; +} + +.token.keyword { + color: #66d9ef; +} + +.token.regex, +.token.important { + color: #fd971f; +} + +.token.important, +.token.bold { + font-weight: bold; +} +.token.italic { + font-style: italic; +} + +.token.entity { + cursor: help; +} + diff --git a/res/prism.js b/res/prism.js new file mode 100644 index 0000000..26e5dda --- /dev/null +++ b/res/prism.js @@ -0,0 +1,1723 @@ +/* PrismJS 1.29.0 +https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript */ +/// + +var _self = (typeof window !== 'undefined') + ? window // if in browser + : ( + (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope) + ? self // if in worker + : {} // if in node js + ); + +/** + * Prism: Lightweight, robust, elegant syntax highlighting + * + * @license MIT + * @author Lea Verou + * @namespace + * @public + */ +var Prism = (function (_self) { + + // Private helper vars + var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i; + var uniqueId = 0; + + // The grammar object for plaintext + var plainTextGrammar = {}; + + + var _ = { + /** + * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the + * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load + * additional languages or plugins yourself. + * + * By setting this value to `true`, Prism will not automatically highlight all code elements on the page. + * + * You obviously have to change this value before the automatic highlighting started. To do this, you can add an + * empty Prism object into the global scope before loading the Prism script like this: + * + * ```js + * window.Prism = window.Prism || {}; + * Prism.manual = true; + * // add a new