feat: add Gk0Wk/codemirror-mode-tiddlywiki5

This commit is contained in:
林一二 2021-09-02 13:16:36 +08:00
parent 72dcfa84ff
commit 0cd349ce59
8 changed files with 65 additions and 0 deletions

View file

@ -0,0 +1 @@
(function(e){"object"==typeof exports&&"object"==typeof module?e(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],e):e(CodeMirror)})(function(e){"use strict";e.defineInitHook(function(e){e.options.hintOptions={completeSingle:!1},e.on("change",function(e,i){e.state.completeActive||"function"!=typeof e.showHint||e.showHint()})}),e.registerHelper("hint","tiddlywiki5",function(i){for(var t=i.getCursor(),r=i.getLine(t.line),o=t.ch,n=t.ch,l=30,s=[".","]","}",">"],c=["[","{","|",'"'];o;){var f=r.charAt(o-1);if(n-o>l||s.includes(f))return null;if(c.includes(f))break;o--}if(0==o)return null;var d=o!==n&&r.slice(o,n);return"$"==r.charAt(o)?{list:$tw.wiki.filterTiddlers(`[all[tiddlers]search:title:literal[${d}]!prefix[$:/state]]`),from:e.Pos(t.line,o),to:e.Pos(t.line,n)}:{list:$tw.wiki.filterTiddlers(`[all[tiddlers]!is[system]!is[shadow]search:title:literal[${d}]!prefix[$:/state]]`),from:e.Pos(t.line,o),to:e.Pos(t.line,n)}})});

View file

@ -0,0 +1 @@
(function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)})(function(t){"use strict";t.defineMode("tex",function(t,e){function n(t,e){t.cmdState.push(e)}function r(t){return t.cmdState.length>0?t.cmdState[t.cmdState.length-1]:null}function i(t){var e=t.cmdState.pop();e&&e.closeBracket()}function a(t){for(var e=t.cmdState,n=e.length-1;n>=0;n--){var r=e[n];if("DEFAULT"!=r.name)return r}return{styleIdentifier:function(){return null}}}function c(t,e,n){return function(){this.name=t,this.bracketNo=0,this.style=e,this.styles=n,this.argument=null,this.styleIdentifier=function(){return this.styles[this.bracketNo-1]||null},this.openBracket=function(){return this.bracketNo++,"bracket"},this.closeBracket=function(){}}}function o(t,e){t.f=e}function u(t,e){var i;if(t.match(/^\\[a-zA-Z@]+/)){var c=t.current().slice(1);return i=l.hasOwnProperty(c)?l[c]:l.DEFAULT,i=new i,n(e,i),o(e,m),i.style}if(t.match(/^\\[$&%#{}_]/))return"tag";if(t.match(/^\\[,;!\/\\]/))return"tag";if(t.match("\\["))return o(e,function(t,e){return f(t,e,"\\]")}),"keyword";if(t.match("\\("))return o(e,function(t,e){return f(t,e,"\\)")}),"keyword";if(t.match("$$"))return o(e,function(t,e){return f(t,e,"$$")}),"keyword";if(t.match("$"))return o(e,function(t,e){return f(t,e,"$")}),"keyword";var u=t.next();return"%"==u?(t.skipToEnd(),"comment"):"}"==u||"]"==u?(i=r(e),i?(i.closeBracket(u),o(e,m),"bracket"):"error"):"{"==u||"["==u?(i=l.DEFAULT,i=new i,n(e,i),"bracket"):/\d/.test(u)?(t.eatWhile(/[\w.%]/),"atom"):(t.eatWhile(/[\w\-_]/),i=a(e),"begin"==i.name&&(i.argument=t.current()),i.styleIdentifier())}function f(t,e,n){if(t.eatSpace())return null;if(n&&t.match(n))return o(e,u),"keyword";if(t.match(/^\\[a-zA-Z@]+/))return"tag";if(t.match(/^[a-zA-Z]+/))return"variable-2";if(t.match(/^\\[$&%#{}_]/))return"tag";if(t.match(/^\\[,;!\/]/))return"tag";if(t.match(/^[\^_&]/))return"tag";if(t.match(/^[+\-<>|=,\/@!*:;'"`~#?]/))return null;if(t.match(/^(\d+\.\d*|\d*\.\d+|\d+)/))return"number";var r=t.next();return"{"==r||"}"==r||"["==r||"]"==r||"("==r||")"==r?"bracket":"%"==r?(t.skipToEnd(),"comment"):"error"}function m(t,e){var n,a=t.peek();return"{"==a||"["==a?(n=r(e),n.openBracket(a),t.eat(a),o(e,u),"bracket"):/[ \t\r]/.test(a)?(t.eat(a),null):(o(e,u),i(e),u(t,e))}var l={};return l.importmodule=c("importmodule","tag",["string","builtin"]),l.documentclass=c("documentclass","tag",["","atom"]),l.usepackage=c("usepackage","tag",["atom"]),l.begin=c("begin","tag",["atom"]),l.end=c("end","tag",["atom"]),l.label=c("label","tag",["atom"]),l.ref=c("ref","tag",["atom"]),l.eqref=c("eqref","tag",["atom"]),l.cite=c("cite","tag",["atom"]),l.bibitem=c("bibitem","tag",["atom"]),l.Bibitem=c("Bibitem","tag",["atom"]),l.RBibitem=c("RBibitem","tag",["atom"]),l.DEFAULT=function(){this.name="DEFAULT",this.style="tag",this.styleIdentifier=this.openBracket=this.closeBracket=function(){}},{startState:function(){var t=e.inMathMode?function(t,e){return f(t,e)}:u;return{cmdState:[],f:t}},copyState:function(t){return{cmdState:t.cmdState.slice(),f:t.f}},token:function(t,e){return e.f(t,e)},blankLine:function(t){t.f=u,t.cmdState.length=0},lineComment:"%"}}),t.defineMIME("text/x-stex","tex"),t.defineMIME("text/x-latex","tex")});

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,13 @@
{
"version": "0.0.4",
"type": "application/json",
"title": "$:/plugins/Gk0Wk/codemirror-mode-tiddlywiki5",
"plugin-type": "plugin",
"parent-plugin": "$:/plugins/tiddlywiki/codemirror",
"name": "CodeMirror Mode TiddlyWiki5",
"list": "readme",
"description": "TiddlyWiki5 highlighting mode for CodeMirror",
"dependents": [
"$:/plugins/tiddlywiki/codemirror-autocomplete"
]
}

View file

@ -0,0 +1,5 @@
View more on [[GitHub Repo|https://github.com/Gk0Wk/CodeMirror-Mode-TiddlyWiki5]].
Adds Syntax Highlighting for TiddlyWiki5 tiddlers (`text/vnd.tiddlywiki`) to the CodeMirror, along with some other useful editor addon (wikilink hint, macro hint, etc.). Now is under development.
为TiddlyWiki的CodeMirror编辑器添加TiddlyWiki5(`text/vnd.tiddlywiki`)语法高亮,同时还有其他有用的编辑器插件(如Wiki链接自动提示、宏提示等)。现在正在开发中。

View file

@ -0,0 +1 @@
.CodeMirror-hints{z-index:200!important}span.cm-underlined{text-decoration-line:underline}span.cm-superscript{vertical-align:super;font-size:.7em;line-height:.1em}span.cm-subscript{font-size:.7em;line-height:.5}span.cm-quote{font-style:italic;padding-left:.6em;border-left:#444 solid .2em}span.cm-h1{font-weight:700;font-size:1.383em;line-height:1.802em}span.cm-h2{font-weight:600;font-size:1.296em;line-height:1.602em}span.cm-h3{font-weight:500;font-size:1.215em;line-height:1.424em}span.cm-h4{font-weight:400;font-size:1.138em;line-height:1.266em}span.cm-h5{font-weight:400;font-size:1.067em;line-height:1.125em}span.cm-h6{font-weight:400}span.link{font-weight:600}span.cm-internallink{text-decoration:none}

View file

@ -0,0 +1,42 @@
{
"tiddlers": [
{
"fields": {
"title": "$:/plugins/tiddlywiki/codemirror/mode/tiddlywiki5/tiddlywiki5.js",
"module-type": "codemirror",
"type": "application/javascript"
},
"file": "mode/tiddlywiki5.js"
},
{
"fields": {
"type": "text/css",
"title": "$:/plugins/Gk0Wk/codemirror-tiddlywiki5/style.css",
"tags": "$:/tags/Stylesheet"
},
"file": "style.css"
},
{
"fields": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/mode/tex/tex.js",
"module-type": "codemirror"
},
"file": "mode/tex.js"
},
{
"fields": {
"title": "$:/plugins/Gk0Wk/codemirror-mode-tiddlywiki5/readme"
},
"file": "readme"
},
{
"fields": {
"type": "application/javascript",
"title": "$:/plugins/tiddlywiki/codemirror/addon/hint/hint-tiddlywiki5.js",
"module-type": "codemirror"
},
"file": "hint/hint-tiddlywiki5.js"
}
]
}

View file

@ -37,6 +37,7 @@
"felixhayashi/hotzone",
"felixhayashi/topstoryview",
"mat/field-value-selector",
"Gk0Wk/codemirror-mode-tiddlywiki5",
"linonetwo/copy-on-select",
"linonetwo/github-external-image",
"linonetwo/inverse-link-and-folder",