Skip to content

Commit 2928eb7

Browse files
authored
Ensure autoHeader dom result is similar to parsed H1 (#811)
1 parent b83622e commit 2928eb7

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/core/render/compiler.js

+5
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export class Compiler {
8282
this.contentBase = router.getBasePath()
8383

8484
const renderer = this._initRenderer()
85+
this.heading = renderer.heading
8586
let compile
8687
const mdConf = config.markdown || {}
8788

@@ -403,6 +404,10 @@ export class Compiler {
403404
return treeTpl(tree)
404405
}
405406

407+
header(text, level) {
408+
return this.heading(text, level)
409+
}
410+
406411
article(text) {
407412
return this.compile(text)
408413
}

src/core/render/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ export function renderMixin(proto) {
117117
const main = dom.getNode('#main')
118118
const firstNode = main.children[0]
119119
if (firstNode && firstNode.tagName !== 'H1') {
120-
const h1 = dom.create('h1')
121-
h1.innerText = activeEl.innerText
122-
dom.before(main, h1)
120+
const h1 = this.compiler.header(activeEl.innerText, 1)
121+
const wrapper = dom.create('div', h1)
122+
dom.before(main, wrapper.children[0])
123123
}
124124
}
125125

0 commit comments

Comments
 (0)