mirror of
https://github.com/docsifyjs/docsify.git
synced 2026-01-25 15:23:21 +00:00
fix : add patch for {docsify-ignore} and {docsify-ignore-all} (#1351)
* revert: Convert {docsify-ignore} and {docsify-ignore-all} to HTML comments
This reverts commit 90d283d340502456a5d8495df596bb4a02ceb39b
* fix: patch for docsify-ignore
* fix test
* fix test
This commit is contained in:
parent
ef32da1dcf
commit
ce316075e0
@ -214,12 +214,24 @@ export class Compiler {
|
||||
nextToc.ignoreSubHeading = true;
|
||||
}
|
||||
|
||||
if (/{docsify-ignore}/g.test(str)) {
|
||||
str = str.replace('{docsify-ignore}', '');
|
||||
nextToc.title = str;
|
||||
nextToc.ignoreSubHeading = true;
|
||||
}
|
||||
|
||||
if (/<!-- {docsify-ignore-all} -->/g.test(str)) {
|
||||
str = str.replace('<!-- {docsify-ignore-all} -->', '');
|
||||
nextToc.title = str;
|
||||
nextToc.ignoreAllSubs = true;
|
||||
}
|
||||
|
||||
if (/{docsify-ignore-all}/g.test(str)) {
|
||||
str = str.replace('{docsify-ignore-all}', '');
|
||||
nextToc.title = str;
|
||||
nextToc.ignoreAllSubs = true;
|
||||
}
|
||||
|
||||
const slug = slugify(config.id || str);
|
||||
const url = router.toURL(router.getCurrentPath(), { id: slug });
|
||||
nextToc.slug = url;
|
||||
|
||||
@ -12,12 +12,24 @@ export const headingCompiler = ({ renderer, router, _self }) =>
|
||||
nextToc.ignoreSubHeading = true;
|
||||
}
|
||||
|
||||
if (/{docsify-ignore}/g.test(str)) {
|
||||
str = str.replace('{docsify-ignore}', '');
|
||||
nextToc.title = str;
|
||||
nextToc.ignoreSubHeading = true;
|
||||
}
|
||||
|
||||
if (/<!-- {docsify-ignore-all} -->/g.test(str)) {
|
||||
str = str.replace('<!-- {docsify-ignore-all} -->', '');
|
||||
nextToc.title = str;
|
||||
nextToc.ignoreAllSubs = true;
|
||||
}
|
||||
|
||||
if (/{docsify-ignore-all}/g.test(str)) {
|
||||
str = str.replace('{docsify-ignore-all}', '');
|
||||
nextToc.title = str;
|
||||
nextToc.ignoreAllSubs = true;
|
||||
}
|
||||
|
||||
const slug = slugify(config.id || str);
|
||||
const url = router.toURL(router.getCurrentPath(), { id: slug });
|
||||
nextToc.slug = url;
|
||||
|
||||
@ -254,9 +254,7 @@ describe('render', function() {
|
||||
|
||||
it('ignore', async function() {
|
||||
const { docsify } = await init();
|
||||
const output = docsify.compiler.compile(
|
||||
'## h2 tag <!-- {docsify-ignore} -->'
|
||||
);
|
||||
const output = docsify.compiler.compile('## h2 tag {docsify-ignore}');
|
||||
expectSameDom(
|
||||
output,
|
||||
`
|
||||
@ -268,10 +266,26 @@ describe('render', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('ignore-html-comments', async function() {
|
||||
const { docsify } = await init();
|
||||
const output = docsify.compiler.compile(
|
||||
'## h2 tag ignore <!-- {docsify-ignore} -->'
|
||||
);
|
||||
expectSameDom(
|
||||
output,
|
||||
`
|
||||
<h2 id="h2-tag-ignore">
|
||||
<a href="#/?id=h2-tag-ignore" data-id="h2-tag-ignore" class="anchor">
|
||||
<span>h2 tag ignore </span>
|
||||
</a>
|
||||
</h2>`
|
||||
);
|
||||
});
|
||||
|
||||
it('ignore-all', async function() {
|
||||
const { docsify } = await init();
|
||||
const output = docsify.compiler.compile(
|
||||
`# h1 tag <!-- {docsify-ignore-all} -->` + `\n## h2 tag`
|
||||
`# h1 tag {docsify-ignore-all}` + `\n## h2 tag`
|
||||
);
|
||||
expectSameDom(
|
||||
output,
|
||||
@ -288,6 +302,27 @@ describe('render', function() {
|
||||
</h2>`
|
||||
);
|
||||
});
|
||||
|
||||
it('ignore-all-html-comments', async function() {
|
||||
const { docsify } = await init();
|
||||
const output = docsify.compiler.compile(
|
||||
`# h1 tag ignore <!-- {docsify-ignore-all} -->` + `\n## h2 tag`
|
||||
);
|
||||
expectSameDom(
|
||||
output,
|
||||
`
|
||||
<h1 id="h1-tag-ignore">
|
||||
<a href="#/?id=h1-tag-ignore" data-id="h1-tag-ignore" class="anchor">
|
||||
<span>h1 tag ignore </span>
|
||||
</a>
|
||||
</h1>
|
||||
<h2 id="h2-tag">
|
||||
<a href="#/?id=h2-tag" data-id="h2-tag" class="anchor">
|
||||
<span>h2 tag</span>
|
||||
</a>
|
||||
</h2>`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('link', function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user