From 83c3c027d0596f36ece710a0b69d2910da1e7e42 Mon Sep 17 00:00:00 2001 From: "Helmut K. C. Tessarek" Date: Tue, 5 Nov 2019 08:18:05 -0500 Subject: [PATCH] Desktop, Mobile: Fix TOC with special characters (#2052) --- ReactNativeClient/lib/renderers/MdToHtml.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ReactNativeClient/lib/renderers/MdToHtml.js b/ReactNativeClient/lib/renderers/MdToHtml.js index c8feb38ea..659e02dfb 100644 --- a/ReactNativeClient/lib/renderers/MdToHtml.js +++ b/ReactNativeClient/lib/renderers/MdToHtml.js @@ -28,9 +28,13 @@ const plugins = { emoji: { module: require('markdown-it-emoji') }, insert: { module: require('markdown-it-ins') }, multitable: { module: require('markdown-it-multimd-table'), options: { enableMultilineRows: true, enableRowspan: true } }, - toc: { module: require('markdown-it-toc-done-right'), options: { listType: 'ul' } }, + toc: { module: require('markdown-it-toc-done-right'), options: { listType: 'ul', slugify: uslugify } }, }; +function uslugify(s) { + return uslug(s); +} + class MdToHtml { constructor(options = null) { if (!options) options = {}; @@ -145,9 +149,7 @@ class MdToHtml { if (Setting.value('markdown.plugin.fountain')) markdownIt.use(rules.fountain(context, ruleOptions)); markdownIt.use(rules.highlight_keywords(context, ruleOptions)); markdownIt.use(rules.code_inline(context, ruleOptions)); - markdownIt.use(markdownItAnchor, { - slugify: s => uslug(s), - }); + markdownIt.use(markdownItAnchor, { slugify: uslugify }); for (let key in plugins) { if (Setting.value(`markdown.plugin.${key}`)) markdownIt.use(plugins[key].module, plugins[key].options);