diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 2f7ce1528..77d888fae 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -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 || {} @@ -381,6 +382,10 @@ export class Compiler { return treeTpl(tree) } + header(text, level) { + return this.heading(text, level) + } + article(text) { return this.compile(text) } diff --git a/src/core/render/index.js b/src/core/render/index.js index b4d16006d..5ddb4c31a 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -115,9 +115,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]) } }