marked: fix code block line number

This commit is contained in:
Le Tan 2019-06-14 19:42:27 +08:00
parent 09df438f2e
commit ada7400306
5 changed files with 21 additions and 7 deletions

View File

@ -1,3 +1,5 @@
var VRenderer = 'hoedown';
// Use Marked to highlight code blocks in edit mode. // Use Marked to highlight code blocks in edit mode.
marked.setOptions({ marked.setOptions({
highlight: function(code, lang) { highlight: function(code, lang) {

View File

@ -34,6 +34,8 @@ var getHeadingLevel = function(h) {
return level; return level;
} }
var VRenderer = 'markdown-it';
// There is a VMarkdownitOption struct passed in. // There is a VMarkdownitOption struct passed in.
// var VMarkdownitOption = { html, breaks, linkify, sub, sup }; // var VMarkdownitOption = { html, breaks, linkify, sub, sup };
var mdit = window.markdownit({ var mdit = window.markdownit({

View File

@ -102,6 +102,10 @@ if (typeof VOS == 'undefined') {
VOS = 'win'; VOS = 'win';
} }
if (typeof VRenderer == 'undefined') {
VRenderer = 'markdown-it';
}
if (typeof handleMathjaxReady == 'undefined') { if (typeof handleMathjaxReady == 'undefined') {
var handleMathjaxReady = function() {}; var handleMathjaxReady = function() {};
} }
@ -1241,13 +1245,15 @@ var renderCodeBlockLineNumber = function() {
} }
} }
// Delete the last extra row. if (VRenderer != 'marked') {
var tables = document.getElementsByTagName('table'); // Delete the last extra row.
for (var i = 0; i < tables.length; ++i) { var tables = document.getElementsByTagName('table');
var table = tables[i]; for (var i = 0; i < tables.length; ++i) {
if (table.classList.contains("hljs-ln")) { var table = tables[i];
var rowCount = table.rows.length; if (table.classList.contains("hljs-ln")) {
table.deleteRow(rowCount - 1); var rowCount = table.rows.length;
table.deleteRow(rowCount - 1);
}
} }
} }
}; };

View File

@ -2,6 +2,8 @@ var renderer = new marked.Renderer();
var toc = []; // Table of contents as a list var toc = []; // Table of contents as a list
var nameCounter = 0; var nameCounter = 0;
var VRenderer = 'marked';
renderer.heading = function(text, level) { renderer.heading = function(text, level) {
// Use number to avoid issues with Chinese // Use number to avoid issues with Chinese
var escapedText = 'toc_' + nameCounter++; var escapedText = 'toc_' + nameCounter++;

View File

@ -1,3 +1,5 @@
var VRenderer = 'showdown';
var renderer = new showdown.Converter({simplifiedAutoLink: 'true', var renderer = new showdown.Converter({simplifiedAutoLink: 'true',
excludeTrailingPunctuationFromURLs: 'true', excludeTrailingPunctuationFromURLs: 'true',
strikethrough: 'true', strikethrough: 'true',