Commit c17ffaa2 authored by montefuscolo's avatar montefuscolo

[ENH] PluginCode now accepts the "theme" parameter

parent a4753126
......@@ -234,12 +234,13 @@ jQuery.fn.extend({
var textarea;
settings.parent.visible(function() {
var syntax, wrap, lineNumbers;
var syntax, wrap, theme, lineNumbers;
if (!o.is(':input')) {
syntax = o.data('syntax');
lineNumbers = o.data('line-numbers');
wrap = o.data('wrap');
theme = o.data('theme');
textarea = $('<textarea class="preCodeMirror"></textarea>')
.val(o.text())
......@@ -248,6 +249,7 @@ jQuery.fn.extend({
if (syntax) textarea.data('syntax', (geshiColors[syntax] ? geshiColors[syntax] : syntax));
if (lineNumbers) textarea.data('line-numbers', lineNumbers);
if (wrap) textarea.data('wrap', wrap);
if (theme) textarea.data('theme', theme);
settings.readOnly = true;
} else {
textarea = o;
......@@ -282,6 +284,7 @@ jQuery.fn.extend({
var mode = applyOverride('syntax', 'mode');
lineNumbers = applyOverride('line-numbers', 'lineNumbers');
wrap = applyOverride('wrap', 'lineWrapping');
theme = applyOverride('theme', 'theme');
if (s.readOnly) {
if (!syntaxHighlighter.modes.hasOwnProperty(mode)) {
......
......@@ -85,6 +85,13 @@ function wikiplugin_code_info()
'default' => '0',
'advanced' => true,
),
'theme' => array(
'required' => false,
'name' => tra('Theme'),
'description' => tra('Any supported theme listed at https://codemirror.net/demo/theme.html'),
'since' => '1',
'filter' => 'text',
),
),
);
}
......@@ -128,10 +135,17 @@ function wikiplugin_code($data, $params)
.' white-space:-pre-wrap;'
.' white-space:-o-pre-wrap;'
.' word-wrap:break-word;';
if (!isset($theme) && isset($prefs['feature_syntax_highlighter_theme'])) {
$theme = $prefs['feature_syntax_highlighter_theme'];
}
}
$out = (isset($caption) ? '<div class="codecaption">'.$caption.'</div>' : "" )
. '<pre class="codelisting" '
. (isset($theme) ? ' data-theme="' . $theme . '" ' : '')
. (isset($colors) ? ' data-syntax="' . $colors . '" ' : '')
. (isset($ln) ? ' data-line-numbers="' . $ln . '" ' : '')
. (isset($wrap) ? ' data-wrap="' . $wrap . '" ' : '')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment