From 2dc2fbe162f8a24543caeace106550177f5df0c4 Mon Sep 17 00:00:00 2001 From: Cheng-Han, Wu Date: Mon, 22 Feb 2016 08:58:06 +0800 Subject: Change markdown engine from remarkable to markdown-it --- public/js/syncscroll.js | 188 ++++++++++++++++++------------------------------ 1 file changed, 68 insertions(+), 120 deletions(-) (limited to 'public/js/syncscroll.js') diff --git a/public/js/syncscroll.js b/public/js/syncscroll.js index 0d858db7..85a62c32 100644 --- a/public/js/syncscroll.js +++ b/public/js/syncscroll.js @@ -1,143 +1,91 @@ -// -// Inject line numbers for sync scroll. Notes: -// -// - We track only headings and paragraphs on first level. That's enougth. -// - Footnotes content causes jumps. Level limit filter it automatically. -// -md.renderer.rules.blockquote_open = function (tokens, idx /*, options, env */ ) { - if (tokens[idx].lines && tokens[idx].level === 0) { - var startline = tokens[idx].lines[0] + 1; - var endline = tokens[idx].lines[1]; - return '
\n'; +// Inject line numbers for sync scroll. + +function addPart(tokens, idx) { + if (tokens[idx].map && tokens[idx].level === 0) { + var startline = tokens[idx].map[0] + 1; + var endline = tokens[idx].map[1]; + tokens[idx].attrJoin('class', 'part'); + tokens[idx].attrJoin('data-startline', startline); + tokens[idx].attrJoin('data-endline', endline); } - return '
\n'; -}; +} -md.renderer.rules.table_open = function (tokens, idx /*, options, env */ ) { - if (tokens[idx].lines && tokens[idx].level === 0) { - var startline = tokens[idx].lines[0] + 1; - var endline = tokens[idx].lines[1]; - return '\n'; - } - return '
\n'; +md.renderer.rules.blockquote_open = function (tokens, idx, options, env, self) { + tokens[idx].attrJoin('class', 'raw'); + addPart(tokens, idx); + return self.renderToken.apply(self, arguments); }; - -md.renderer.rules.bullet_list_open = function (tokens, idx /*, options, env */ ) { - if (tokens[idx].lines && tokens[idx].level === 0) { - var startline = tokens[idx].lines[0] + 1; - var endline = tokens[idx].lines[1]; - return '