From 89fd89633771efe2aaa9cc19722223e3a3739b55 Mon Sep 17 00:00:00 2001 From: kts of kettek Date: Thu, 17 Dec 2015 17:06:21 -0800 Subject: [PATCH] Default markdown formatter is now markdown-it. This gives access to extended functionality such as: table of contents generation, super text, section tags, definition lists, and much more. --- index.js | 38 +++++++++++--------------------------- package.json | 7 ++++++- wiki/style.css | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 28 deletions(-) diff --git a/index.js b/index.js index 3c992cd..25a4f96 100644 --- a/index.js +++ b/index.js @@ -327,34 +327,18 @@ qwiki.addMIMEtype('png', 'image/png'); qwiki.addMIMEtype('svg', 'image/svg+xml'); qwiki.addMIMEtype('css', 'text/css'); -var m_markdown = require("markdown").markdown; -qwiki.addFormat('md', 'Markdown', function(source) { - // parse the markdown into a tree and grab the link references - var tree = m_markdown.parse( source.toString() ); - if (!tree[1] || !tree[1].references) { - tree.splice(1, 0, { 'references' : {} }); - } - var refs = tree[1].references; - // iterate through the tree finding link references - ( function find_link_refs( jsonml ) { - if (jsonml[0] === "link_ref") { - var ref = jsonml[1].ref; - if (!refs[ref]) { - refs[ref] = { - href: ref.replace(/\s+/, "_" ) - }; - } - } else { - for (var item in jsonml) { - if (Array.isArray(jsonml[item])) { - find_link_refs(jsonml[item]); - } - } - } - } )( tree ); - // convert the tree into html - return m_markdown.renderJsonML(m_markdown.toHTMLTree(tree)); +var m_markdownit = require('markdown-it')({ + typographer: true }); +m_markdownit.use(require('markdown-it-anchor')); +m_markdownit.use(require('markdown-it-table-of-contents'), {includeLevel: "2-8"}); +m_markdownit.use(require('markdown-it-deflist')); +m_markdownit.use(require('markdown-it-header-sections')); +m_markdownit.use(require('markdown-it-sup')); +qwiki.addFormat('md', 'Markdown', function(source) { + return m_markdownit.render(source); +}); + qwiki.setDefault('format', 'md'); // **** DEFAULT diff --git a/package.json b/package.json index 27687f0..349d8ee 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,11 @@ "author": "kts of kettek (https://kettek.net/)", "license": "GPLv3", "dependencies": { - "markdown": "^0.5.0" + "markdown-it": "^5.0.2", + "markdown-it-anchor": "^2.3.2", + "markdown-it-deflist": "^2.0.0", + "markdown-it-header-sections": "^0.2.0", + "markdown-it-sup": "^1.0.0", + "markdown-it-table-of-contents": "^0.1.2" } } diff --git a/wiki/style.css b/wiki/style.css index 9148e1c..e128a5d 100644 --- a/wiki/style.css +++ b/wiki/style.css @@ -322,3 +322,42 @@ textarea:focus,input:focus { #content ul { margin-left: 1em; } +/* content definition list styling */ +dl { +} +dt { + font-weight: bold; + color: #3c3c57; + padding-left: 1em; +} +dd { + text-align: left; +} +/* content table styling */ +table { + box-shadow: rgba(0,0,0, 0.2) 0px 0px 4px; + -moz-box-shadow: rgba(0,0,0, 0.2) 0px 0px 4px; + -webkit-box-shadow: rgba(0,0,0, 0.2) 0px 0px 4px; +} +thead { + background-color: #3c3c57; + color: #ececf7; +} +tr { +} +th { + padding: 0.5em; +} +tbody { +} +td { + padding: 0.5em; + background-color: #fcfce2; + box-shadow: rgba(0,0,0, 0.2) 0px 0px 4px; + -moz-box-shadow: rgba(0,0,0, 0.2) 0px 0px 4px; + -webkit-box-shadow: rgba(0,0,0, 0.2) 0px 0px 4px; +} +/* section */ +section { + padding-left: 0.5em; +}