Installing CodeMirror with vim extensions on Tiddlywiki 5?

164 views
Skip to first unread message

leeand00

unread,
Apr 4, 2018, 12:10:38 AM4/4/18
to TiddlyWiki
After reading someone else's suggestion to do so in the forums, I installed CodeMirror in a new Tiddlywiki...I sort of know how to do it, and I was successful in getting it to work; its best thing ever having what's pretty close to a full vim editor in my tiddlers; but I'm still a little confused about how exactly I did it apart from dragging the tiddler from http://tiddlywiki.com/plugins/tiddlywiki/codemirror/index.html#%24%3A%2Fplugins%2Ftiddlywiki%2Fcodemirror

I'm especially confused about how the MIME types work...although I did manage to get the text/x-python one loaded and working. Is there a better tutorial on how to setup such things somewhere?

Also, how can I incorporate this into future tiddlywiki's that I make from a template when generating them using the node.js version of tw5?

Thank you,
Andrew J. Leer

leeand00

unread,
Apr 4, 2018, 12:15:28 AM4/4/18
to TiddlyWiki
...and one more thing...if I set my tiddlers type to text/x-python I get the code formattting in the editor...but I do not get it in the preview / final result; is there a way to get the code formatting / colorizing in the preview / result as well?

PMario

unread,
Apr 4, 2018, 4:11:09 AM4/4/18
to TiddlyWiki


On Wednesday, April 4, 2018 at 6:15:28 AM UTC+2, leeand00 wrote:
...and one more thing...if I set my tiddlers type to text/x-python I get the code formattting in the editor...but I do not get it  in the preview / final result; is there a way to get the code formatting / colorizing in the preview / result as well?

There is a pending PR which should simplify codemirror handling quite a bit. ...
The initial configurations are done automatically and adding different features is a matter of "drag & drop" installation. ...

Codemirror has a mode that allows cm to be used as a highlighter in view mode. ... But it isn't implemented atm, basically because of the mime-type issue.

Handling mime-types is an unsolved problem. ...

eg: at the moment, if you want to edit CSS code you need to set the tiddler type field to: text/css. Which is fine. The problem is, that TW is able to use macros in CSS mode. ... but... only if type is: text/vnd-tiddlywiki. ...

So we minimum need 2 settings.

1) .. for the real mime-type of the tiddler
2) .. type-mapping, that connects mime-type to view-type
may be
3) .. edit-type, that is completely independent, so user can choose what s/he wants to use in edit mode.

eg: image/svg+xml will work with a standard xml highlighter

We should probably use the same mechanism as highlighter.js already does, for view-mode ... to be compatible and don't confuse existing users. ...

just some thoughts

-mario


Reply all
Reply to author
Forward
0 new messages