From d2bd13da463f7c24138fe124ea170d8e20101d1d Mon Sep 17 00:00:00 2001 From: Chase Sterling Date: Sun, 4 Sep 2016 16:03:16 -0400 Subject: [PATCH] Add back heading anchors via markdown-it-anchors plugin --- bower.json | 1 + realms/__init__.py | 1 + realms/static/js/mdr.js | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/bower.json b/bower.json index 48f1e22..6eaa945 100644 --- a/bower.json +++ b/bower.json @@ -11,6 +11,7 @@ "ace-builds": "~1.2.3", "parsleyjs": "~2.3.10", "markdown-it": "~7.0.0", + "markdown-it-anchor": "https://wzrd.in/standalone/markdown-it-anchor@2.5.0", "js-yaml": "~3.6.0", "store-js": "~1.3.16", "bootswatch-dist": "3.3.6-flatly", diff --git a/realms/__init__.py b/realms/__init__.py index 79b1eeb..6dee5ae 100644 --- a/realms/__init__.py +++ b/realms/__init__.py @@ -230,6 +230,7 @@ assets.register('main.js', 'vendor/handlebars/handlebars.js', 'vendor/js-yaml/dist/js-yaml.js', 'vendor/markdown-it/dist/markdown-it.js', + 'vendor/markdown-it-anchor/index.0', 'js/html-sanitizer-minified.js', # don't minify? 'vendor/highlightjs/highlight.pack.js', 'vendor/parsleyjs/dist/parsley.js', diff --git a/realms/static/js/mdr.js b/realms/static/js/mdr.js index 8de94af..a776496 100644 --- a/realms/static/js/mdr.js +++ b/realms/static/js/mdr.js @@ -52,6 +52,14 @@ var markdownit = window.markdownit({ return ''; // use external default escaping } +}).use(markdownItAnchor, { + level: 1, + // slugify: string => string, + permalink: false, + // renderPermalink: (slug, opts, state, permalink) => {}, + permalinkClass: 'header-anchor', + permalinkSymbol: 'ΒΆ', + permalinkBefore: false }); // Markdown Renderer