Use marked
instead of markdown-js
for Markdown parser of TiddlyWiki 5.
Originally fork from http://bjtools.tiddlyspot.com/
- support fenced code block
- support code highlighting
-
Install the official Markdown and Hightlight.js plugin.
-
Replace
markdown.js
with content of https://raw.githubusercontent.com/chjj/marked/master/lib/marked.js -
Replace
wrapper.js
with
/*\
title: $:/plugins/tiddlywiki/markdown/wrapper.js
type: application/javascript
module-type: parser
Wraps up the marked parser for use in TiddlyWiki5
Originally fork from http://bjtools.tiddlyspot.com
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var hljs = require("$:/plugins/tiddlywiki/highlight/highlight.js");
var marked = require("$:/plugins/tiddlywiki/markdown/markdown.js");
var HighLighter = function(str, lang) {
try {
if (lang && hljs.getLanguage(lang))
return hljs.highlight(lang, str).value;
else
return hljs.highlightAuto(str).value;
} catch (err) {
return '';
}
};
marked.setOptions({
highlight: HighLighter,
renderer: new marked.Renderer(),
gfm: true,
tables: true,
breaks: true,
pedantic: false,
sanitize: false,
smartLists: true,
smartypants: false
});
var MarkdownParser = function(type, text, options) {
this.tree = [{type: "raw", html: marked(text)}];
};
exports["text/x-markdown"] = MarkdownParser;
})();
- Done
An update with markdown-it, supporting LaTeX, see https://gist.github.com/syrte/8062e11d8fec6221820c5f998239af61