Skip to content

Commit

Permalink
Ensure autoHeader dom result is similar to parsed H1 (#811)
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrilf authored Feb 4, 2020
1 parent b83622e commit 2928eb7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class Compiler {
this.contentBase = router.getBasePath()

const renderer = this._initRenderer()
this.heading = renderer.heading
let compile
const mdConf = config.markdown || {}

Expand Down Expand Up @@ -403,6 +404,10 @@ export class Compiler {
return treeTpl(tree)
}

header(text, level) {
return this.heading(text, level)
}

article(text) {
return this.compile(text)
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ export function renderMixin(proto) {
const main = dom.getNode('#main')
const firstNode = main.children[0]
if (firstNode && firstNode.tagName !== 'H1') {
const h1 = dom.create('h1')
h1.innerText = activeEl.innerText
dom.before(main, h1)
const h1 = this.compiler.header(activeEl.innerText, 1)
const wrapper = dom.create('div', h1)
dom.before(main, wrapper.children[0])
}
}

Expand Down

0 comments on commit 2928eb7

Please sign in to comment.