Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class Compiler {
this.router = router;
this.cacheTree = {};
this.toc = [];
this.blockquoteDepth = 0;
this.cacheTOC = {};
this.linkTarget = config.externalLinkTarget || '_blank';
this.linkRel =
Expand Down Expand Up @@ -165,7 +166,10 @@ export class Compiler {
router,
compiler: this,
});
origin.blockquoteCompiler = blockquoteCompiler({ renderer });
origin.blockquoteCompiler = blockquoteCompiler({
renderer,
compiler: this,
});
origin.code = highlightCodeCompiler({ renderer });
origin.link = linkCompiler({
renderer,
Expand Down
11 changes: 8 additions & 3 deletions src/core/render/compiler/blockquote.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const blockquoteCompiler = ({ renderer }) =>
export const blockquoteCompiler = ({ renderer, compiler }) =>
(renderer.blockquote = function ({ tokens }) {
let openTag = '<blockquote>';
let closeTag = '</blockquote>';
Expand Down Expand Up @@ -40,6 +40,11 @@ export const blockquoteCompiler = ({ renderer }) =>
}
}

const body = this.parser.parse(tokens);
return `${openTag}${body}${closeTag}`;
compiler.blockquoteDepth++;
try {
const body = this.parser.parse(tokens);
return `${openTag}${body}${closeTag}`;
} finally {
compiler.blockquoteDepth--;
}
Comment on lines +43 to +49
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
compiler.blockquoteDepth++;
try {
const body = this.parser.parse(tokens);
return `${openTag}${body}${closeTag}`;
} finally {
compiler.blockquoteDepth--;
}
this.__docsifyBlockquoteDepth = (this.__docsifyBlockquoteDepth || 0) + 1;
let body;
try {
body = this.parser.parse(tokens);
} finally {
this.__docsifyBlockquoteDepth = Math.max(0, this._blockquoteDepth - 1);
}

});
4 changes: 3 additions & 1 deletion src/core/render/compiler/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ export const headingCompiler = ({ renderer, router, compiler }) =>
const slug = slugify(config.id || text);
const url = router.toURL(router.getCurrentPath(), { id: slug });
nextToc.slug = stripUrlExceptId(url);
compiler.toc.push(nextToc);
if (!compiler.blockquoteDepth) {
compiler.toc.push(nextToc);
}
Comment on lines +25 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!compiler.blockquoteDepth) {
compiler.toc.push(nextToc);
}
if (!this.__docsifyBlockquoteDepth || this.__docsifyBlockquoteDepth === 0) {
compiler.toc.push(nextToc);
}


// Note: tabindex="-1" allows programmatically focusing on heading
// elements after navigation. This is preferred over focusing on the link
Expand Down
Loading