1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-28 04:19:56 +00:00

Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bram Chen 2015-01-10 22:06:51 +08:00
commit 4c7916b0e1
7 changed files with 87 additions and 27 deletions

View File

@ -171,7 +171,7 @@ Widget.prototype.evaluateMacroModule = function(name,actualParams,defaultValue)
else for(var i=0; i<actualParams.length; ++i) { else for(var i=0; i<actualParams.length; ++i) {
args.push(actualParams[i].value); args.push(actualParams[i].value);
} }
return macro.run.apply(this,args).toString(); return (macro.run.apply(this,args) || "").toString();
} else { } else {
return defaultValue; return defaultValue;
} }

View File

@ -1 +1 @@
.hljs{display:block;padding:.5em;background:#f0f0f0}.hljs,.hljs-subst,.hljs-tag .hljs-title,.lisp .hljs-title,.clojure .hljs-built_in,.nginx .hljs-title{color:black}.hljs-string,.hljs-title,.hljs-constant,.hljs-parent,.hljs-tag .hljs-value,.hljs-rules .hljs-value,.hljs-rules .hljs-value .hljs-number,.hljs-preprocessor,.hljs-pragma,.haml .hljs-symbol,.ruby .hljs-symbol,.ruby .hljs-symbol .hljs-string,.hljs-aggregate,.hljs-template_tag,.django .hljs-variable,.smalltalk .hljs-class,.hljs-addition,.hljs-flow,.hljs-stream,.bash .hljs-variable,.apache .hljs-tag,.apache .hljs-cbracket,.tex .hljs-command,.tex .hljs-special,.erlang_repl .hljs-function_or_atom,.asciidoc .hljs-header,.markdown .hljs-header,.coffeescript .hljs-attribute{color:#800}.smartquote,.hljs-comment,.hljs-annotation,.hljs-template_comment,.diff .hljs-header,.hljs-chunk,.asciidoc .hljs-blockquote,.markdown .hljs-blockquote{color:#888}.hljs-number,.hljs-date,.hljs-regexp,.hljs-literal,.hljs-hexcolor,.smalltalk .hljs-symbol,.smalltalk .hljs-char,.go .hljs-constant,.hljs-change,.lasso .hljs-variable,.makefile .hljs-variable,.asciidoc .hljs-bullet,.markdown .hljs-bullet,.asciidoc .hljs-link_url,.markdown .hljs-link_url{color:#080}.hljs-label,.hljs-javadoc,.ruby .hljs-string,.hljs-decorator,.hljs-filter .hljs-argument,.hljs-localvars,.hljs-array,.hljs-attr_selector,.hljs-important,.hljs-pseudo,.hljs-pi,.haml .hljs-bullet,.hljs-doctype,.hljs-deletion,.hljs-envvar,.hljs-shebang,.apache .hljs-sqbracket,.nginx .hljs-built_in,.tex .hljs-formula,.erlang_repl .hljs-reserved,.hljs-prompt,.asciidoc .hljs-link_label,.markdown .hljs-link_label,.vhdl .hljs-attribute,.clojure .hljs-attribute,.asciidoc .hljs-attribute,.lasso .hljs-attribute,.coffeescript .hljs-property,.hljs-phony{color:#88F}.hljs-keyword,.hljs-id,.hljs-title,.hljs-built_in,.hljs-aggregate,.css .hljs-tag,.hljs-javadoctag,.hljs-phpdoc,.hljs-yardoctag,.smalltalk .hljs-class,.hljs-winutils,.bash .hljs-variable,.apache .hljs-tag,.go .hljs-typename,.tex .hljs-command,.asciidoc .hljs-strong,.markdown .hljs-strong,.hljs-request,.hljs-status{font-weight:bold}.asciidoc .hljs-emphasis,.markdown .hljs-emphasis{font-style:italic}.nginx .hljs-built_in{font-weight:normal}.coffeescript .javascript,.javascript .xml,.lasso .markup,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5} .hljs{display:block;overflow-x:auto;padding:.5em;background:#f0f0f0;-webkit-text-size-adjust:none}.hljs,.hljs-subst,.hljs-tag .hljs-title,.nginx .hljs-title{color:#000}.hljs-string,.hljs-title,.hljs-constant,.hljs-parent,.hljs-tag .hljs-value,.hljs-rules .hljs-value,.hljs-preprocessor,.hljs-pragma,.haml .hljs-symbol,.ruby .hljs-symbol,.ruby .hljs-symbol .hljs-string,.hljs-template_tag,.django .hljs-variable,.smalltalk .hljs-class,.hljs-addition,.hljs-flow,.hljs-stream,.bash .hljs-variable,.apache .hljs-tag,.apache .hljs-cbracket,.tex .hljs-command,.tex .hljs-special,.erlang_repl .hljs-function_or_atom,.asciidoc .hljs-header,.markdown .hljs-header,.coffeescript .hljs-attribute{color:#800}.smartquote,.hljs-comment,.hljs-annotation,.diff .hljs-header,.hljs-chunk,.asciidoc .hljs-blockquote,.markdown .hljs-blockquote{color:#888}.hljs-number,.hljs-date,.hljs-regexp,.hljs-literal,.hljs-hexcolor,.smalltalk .hljs-symbol,.smalltalk .hljs-char,.go .hljs-constant,.hljs-change,.lasso .hljs-variable,.makefile .hljs-variable,.asciidoc .hljs-bullet,.markdown .hljs-bullet,.asciidoc .hljs-link_url,.markdown .hljs-link_url{color:#080}.hljs-label,.hljs-javadoc,.ruby .hljs-string,.hljs-decorator,.hljs-filter .hljs-argument,.hljs-localvars,.hljs-array,.hljs-attr_selector,.hljs-important,.hljs-pseudo,.hljs-pi,.haml .hljs-bullet,.hljs-doctype,.hljs-deletion,.hljs-envvar,.hljs-shebang,.apache .hljs-sqbracket,.nginx .hljs-built_in,.tex .hljs-formula,.erlang_repl .hljs-reserved,.hljs-prompt,.asciidoc .hljs-link_label,.markdown .hljs-link_label,.vhdl .hljs-attribute,.clojure .hljs-attribute,.asciidoc .hljs-attribute,.lasso .hljs-attribute,.coffeescript .hljs-property,.hljs-phony{color:#88f}.hljs-keyword,.hljs-id,.hljs-title,.hljs-built_in,.css .hljs-tag,.hljs-javadoctag,.hljs-phpdoc,.hljs-dartdoc,.hljs-yardoctag,.smalltalk .hljs-class,.hljs-winutils,.bash .hljs-variable,.apache .hljs-tag,.hljs-type,.hljs-typename,.tex .hljs-command,.asciidoc .hljs-strong,.markdown .hljs-strong,.hljs-request,.hljs-status{font-weight:bold}.asciidoc .hljs-emphasis,.markdown .hljs-emphasis{font-style:italic}.nginx .hljs-built_in{font-weight:normal}.coffeescript .javascript,.javascript .xml,.lasso .markup,.tex .hljs-formula,.xml .javascript,.xml .vbscript,.xml .css,.xml .hljs-cdata{opacity:.5}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -6,9 +6,17 @@
"type": "application/javascript", "type": "application/javascript",
"title": "$:/plugins/tiddlywiki/highlight/highlight.js", "title": "$:/plugins/tiddlywiki/highlight/highlight.js",
"module-type": "library" "module-type": "library"
}
},
{
"file": "registerlanguages.pack.js",
"fields": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/highlight/registerlanguages.js",
"module-type": "library"
}, },
"prefix": "var hljs;if($tw.browser){\n", "prefix": "var hljs = require(\"$:/plugins/tiddlywiki/highlight/highlight.js\");\n",
"suffix": "}\nexports.hljs = hljs;\n" "suffix": "\nexports.hljs = hljs;\n"
}, },
{ {
"file": "default.css", "file": "default.css",

View File

@ -13,11 +13,9 @@ Wraps up the fenced code blocks parser for highlight and use in TiddlyWiki5
"use strict"; "use strict";
var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock; var CodeBlockWidget = require("$:/core/modules/widgets/codeblock.js").codeblock;
//register languages requires hljs for us
if($tw.browser) { var hljs = require("$:/plugins/tiddlywiki/highlight/registerlanguages.js").hljs;
var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js").hljs; hljs.configure({tabReplace: " "});
hljs.configure({tabReplace: " "});
}
CodeBlockWidget.prototype.postRender = function() { CodeBlockWidget.prototype.postRender = function() {
var domNode = this.domNodes[0]; var domNode = this.domNodes[0];
@ -25,6 +23,16 @@ CodeBlockWidget.prototype.postRender = function() {
domNode.className = this.language.toLowerCase(); domNode.className = this.language.toLowerCase();
hljs.highlightBlock(domNode); hljs.highlightBlock(domNode);
} }
else if(!$tw.browser && this.language && this.language.indexOf("/") == -1 ){
try{
domNode.className = this.language.toLowerCase() + " hljs";
domNode.children[0].innerHTML = hljs.fixMarkup(hljs.highlight(this.language, this.getAttribute("code")).value);
}
catch(err) {
//can't easily tell if a language is registered or not in the packed version of hightlight.js
//so we silently fail and the codeblock remains unchanged
}
}
}; };
})(); })();

View File

@ -6,51 +6,94 @@ tags: [[$:/tags/Stylesheet]]
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ /* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
/* Original theme - https://github.com/chriskempson/tomorrow-theme */ /* Original theme - https://github.com/chriskempson/tomorrow-theme */
/* http://jmblog.github.com/color-themes-for-google-code-highlightjs */ /* http://jmblog.github.com/color-themes-for-google-code-highlightjs */
.tomorrow-comment, pre .comment, pre .title {
/* Tomorrow Comment */
.hljs-comment {
color: #969896; color: #969896;
} }
.tomorrow-red, pre .variable, pre .attribute, pre .tag, pre .regexp, pre .ruby .constant, pre .xml .tag .title, pre .xml .pi, pre .xml .doctype, pre .html .doctype, pre .css .id, pre .css .class, pre .css .pseudo { /* Tomorrow Red */
.hljs-variable,
.hljs-attribute,
.hljs-tag,
.hljs-regexp,
.ruby .hljs-constant,
.xml .hljs-tag .hljs-title,
.xml .hljs-pi,
.xml .hljs-doctype,
.html .hljs-doctype,
.css .hljs-id,
.css .hljs-class,
.css .hljs-pseudo {
color: #cc6666; color: #cc6666;
} }
.tomorrow-orange, pre .number, pre .preprocessor, pre .pragma, pre .built_in, pre .literal, pre .params, pre .constant { /* Tomorrow Orange */
.hljs-number,
.hljs-preprocessor,
.hljs-pragma,
.hljs-built_in,
.hljs-literal,
.hljs-params,
.hljs-constant {
color: #de935f; color: #de935f;
} }
.tomorrow-yellow, pre .ruby .class .title, pre .css .rules .attribute { /* Tomorrow Yellow */
.ruby .hljs-class .hljs-title,
.css .hljs-rules .hljs-attribute {
color: #f0c674; color: #f0c674;
} }
.tomorrow-green, pre .string, pre .value, pre .inheritance, pre .header, pre .ruby .symbol, pre .xml .cdata { /* Tomorrow Green */
.hljs-string,
.hljs-value,
.hljs-inheritance,
.hljs-header,
.ruby .hljs-symbol,
.xml .hljs-cdata {
color: #b5bd68; color: #b5bd68;
} }
.tomorrow-aqua, pre .css .hexcolor { /* Tomorrow Aqua */
.hljs-title,
.css .hljs-hexcolor {
color: #8abeb7; color: #8abeb7;
} }
.tomorrow-blue, pre .function, pre .python .decorator, pre .python .title, pre .ruby .function .title, pre .ruby .title .keyword, pre .perl .sub, pre .javascript .title, pre .coffeescript .title { /* Tomorrow Blue */
.hljs-function,
.python .hljs-decorator,
.python .hljs-title,
.ruby .hljs-function .hljs-title,
.ruby .hljs-title .hljs-keyword,
.perl .hljs-sub,
.javascript .hljs-title,
.coffeescript .hljs-title {
color: #81a2be; color: #81a2be;
} }
.tomorrow-purple, pre .keyword, pre .javascript .function { /* Tomorrow Purple */
.hljs-keyword,
.javascript .hljs-function {
color: #b294bb; color: #b294bb;
} }
pre code { .hljs {
display: block; display: block;
overflow-x: auto;
background: #1d1f21; background: #1d1f21;
color: #c5c8c6; color: #c5c8c6;
padding: 0.5em; padding: 0.5em;
-webkit-text-size-adjust: none;
} }
pre .coffeescript .javascript, .coffeescript .javascript,
pre .javascript .xml, .javascript .xml,
pre .tex .formula, .tex .hljs-formula,
pre .xml .javascript, .xml .javascript,
pre .xml .vbscript, .xml .vbscript,
pre .xml .css, .xml .css,
pre .xml .cdata { .xml .hljs-cdata {
opacity: 0.5; opacity: 0.5;
} }