Skip to content

Commit 8b7dbaa

Browse files
committed
revert: Convert {docsify-ignore} and {docsify-ignore-all} to HTML comments
This reverts commit 90d283d
1 parent e474ea8 commit 8b7dbaa

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

docs/more-pages.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,24 @@ A custom sidebar can also automatically generate a table of contents by setting
114114

115115
## Ignoring Subheaders
116116

117-
When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `<!-- {docsify-ignore} -->` to it.
117+
When `subMaxLevel` is set, each header is automatically added to the table of contents by default. If you want to ignore a specific header, add `{docsify-ignore}` to it.
118118

119119
```markdown
120120
# Getting Started
121121

122-
## Header <!-- {docsify-ignore} -->
122+
## Header {docsify-ignore}
123123

124124
This header won't appear in the sidebar table of contents.
125125
```
126126

127-
To ignore all headers on a specific page, you can use `<!-- {docsify-ignore-all} -->` on the first header of the page.
127+
To ignore all headers on a specific page, you can use `{docsify-ignore-all}` on the first header of the page.
128128

129129
```markdown
130-
# Getting Started <!-- {docsify-ignore-all} -->
130+
# Getting Started {docsify-ignore-all}
131131

132132
## Header
133133

134134
This header won't appear in the sidebar table of contents.
135135
```
136136

137-
Both `<!-- {docsify-ignore} -->` and `<!-- {docsify-ignore-all} -->` will not be rendered on the page when used.
137+
Both `{docsify-ignore}` and `{docsify-ignore-all}` will not be rendered on the page when used.

src/core/render/compiler.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,14 @@ export class Compiler {
208208
let { str, config } = getAndRemoveConfig(text);
209209
const nextToc = { level, title: str };
210210

211-
if (/<!-- {docsify-ignore} -->/g.test(str)) {
212-
str = str.replace('<!-- {docsify-ignore} -->', '');
211+
if (/{docsify-ignore}/g.test(str)) {
212+
str = str.replace('{docsify-ignore}', '');
213213
nextToc.title = str;
214214
nextToc.ignoreSubHeading = true;
215215
}
216216

217-
if (/<!-- {docsify-ignore-all} -->/g.test(str)) {
218-
str = str.replace('<!-- {docsify-ignore-all} -->', '');
217+
if (/{docsify-ignore-all}/g.test(str)) {
218+
str = str.replace('{docsify-ignore-all}', '');
219219
nextToc.title = str;
220220
nextToc.ignoreAllSubs = true;
221221
}

src/core/render/compiler/headline.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ export const headingCompiler = ({ renderer, router, _self }) =>
66
let { str, config } = getAndRemoveConfig(text);
77
const nextToc = { level, title: str };
88

9-
if (/<!-- {docsify-ignore} -->/g.test(str)) {
10-
str = str.replace('<!-- {docsify-ignore} -->', '');
9+
if (/{docsify-ignore}/g.test(str)) {
10+
str = str.replace('{docsify-ignore}', '');
1111
nextToc.title = str;
1212
nextToc.ignoreSubHeading = true;
1313
}
1414

15-
if (/<!-- {docsify-ignore-all} -->/g.test(str)) {
16-
str = str.replace('<!-- {docsify-ignore-all} -->', '');
15+
if (/{docsify-ignore-all}/g.test(str)) {
16+
str = str.replace('{docsify-ignore-all}', '');
1717
nextToc.title = str;
1818
nextToc.ignoreAllSubs = true;
1919
}

test/unit/render.test.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ describe('render', function() {
254254

255255
it('ignore', async function() {
256256
const { docsify } = await init();
257-
const output = docsify.compiler.compile(
258-
'## h2 tag <!-- {docsify-ignore} -->'
259-
);
257+
const output = docsify.compiler.compile('## h2 tag {docsify-ignore}');
260258
expectSameDom(
261259
output,
262260
`
@@ -271,7 +269,7 @@ describe('render', function() {
271269
it('ignore-all', async function() {
272270
const { docsify } = await init();
273271
const output = docsify.compiler.compile(
274-
`# h1 tag <!-- {docsify-ignore-all} -->` + `\n## h2 tag`
272+
`# h1 tag {docsify-ignore-all}` + `\n## h2 tag`
275273
);
276274
expectSameDom(
277275
output,

0 commit comments

Comments
 (0)