From 56b669a0272fa6e5c323d70f17a104568b0dc3bf Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Sun, 20 Oct 2019 14:18:21 +0800 Subject: [PATCH] Fix meta break setting in slide mode When `RevealMarkdown.initialize` is called, it use `md.render` to render markdown, but no until we parse meta, the md.options.breaks would be default value we set in extra.js. So this commit move forward the whole meta parsing block. Ensure line break setting changed before `md.render` get called. Signed-off-by: Yukai Huang --- public/js/slide.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/public/js/slide.js b/public/js/slide.js index 9ba3da54..61546339 100644 --- a/public/js/slide.js +++ b/public/js/slide.js @@ -49,6 +49,15 @@ const deps = [{ } }] +// options from yaml meta +const meta = JSON.parse($('#meta').text()) +// breaks +if (typeof meta.breaks === 'boolean') { + md.options.breaks = meta.breaks +} else { + md.options.breaks = window.defaultUseHardbreak +} + const slideOptions = { separator: '^(\r\n?|\n)---(\r\n?|\n)$', verticalSeparator: '^(\r\n?|\n)----(\r\n?|\n)$' @@ -70,8 +79,6 @@ const defaultOptions = { dependencies: deps } -// options from yaml meta -const meta = JSON.parse($('#meta').text()) var options = meta.slideOptions || {} if (Object.hasOwnProperty.call(options, 'spotlight')) { @@ -103,12 +110,6 @@ if (meta.dir && typeof meta.dir === 'string' && meta.dir === 'rtl') { } else { options.rtl = false } -// breaks -if (typeof meta.breaks === 'boolean' && !meta.breaks) { - md.options.breaks = false -} else { - md.options.breaks = true -} // options from URL query string const queryOptions = Reveal.getQueryHash() || {}