Skip to content

Commit 56b669a

Browse files
committed
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>
1 parent fd155fa commit 56b669a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

public/js/slide.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ const deps = [{
4949
}
5050
}]
5151

52+
// options from yaml meta
53+
const meta = JSON.parse($('#meta').text())
54+
// breaks
55+
if (typeof meta.breaks === 'boolean') {
56+
md.options.breaks = meta.breaks
57+
} else {
58+
md.options.breaks = window.defaultUseHardbreak
59+
}
60+
5261
const slideOptions = {
5362
separator: '^(\r\n?|\n)---(\r\n?|\n)$',
5463
verticalSeparator: '^(\r\n?|\n)----(\r\n?|\n)$'
@@ -70,8 +79,6 @@ const defaultOptions = {
7079
dependencies: deps
7180
}
7281

73-
// options from yaml meta
74-
const meta = JSON.parse($('#meta').text())
7582
var options = meta.slideOptions || {}
7683

7784
if (Object.hasOwnProperty.call(options, 'spotlight')) {
@@ -103,12 +110,6 @@ if (meta.dir && typeof meta.dir === 'string' && meta.dir === 'rtl') {
103110
} else {
104111
options.rtl = false
105112
}
106-
// breaks
107-
if (typeof meta.breaks === 'boolean' && !meta.breaks) {
108-
md.options.breaks = false
109-
} else {
110-
md.options.breaks = true
111-
}
112113

113114
// options from URL query string
114115
const queryOptions = Reveal.getQueryHash() || {}

0 commit comments

Comments
 (0)