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 <yukaihuangtw@gmail.com>
This commit is contained in:
Yukai Huang 2019-10-20 14:18:21 +08:00
parent fd155fa74d
commit 56b669a027
No known key found for this signature in database
GPG Key ID: D4D3B2F0E99D4914
1 changed files with 9 additions and 8 deletions

View File

@ -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() || {}