Skip to content

Commit

Permalink
revert: Convert {docsify-ignore} and {docsify-ignore-all} to HTML com…
Browse files Browse the repository at this point in the history
…ments

This reverts commit 90d283d
  • Loading branch information
sy-records committed Aug 22, 2020
1 parent e474ea8 commit 8b7dbaa
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
10 changes: 5 additions & 5 deletions docs/more-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,24 @@ A custom sidebar can also automatically generate a table of contents by setting

## Ignoring Subheaders

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.
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.

```markdown
# Getting Started

## Header <!-- {docsify-ignore} -->
## Header {docsify-ignore}

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

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

```markdown
# Getting Started <!-- {docsify-ignore-all} -->
# Getting Started {docsify-ignore-all}

## Header

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

Both `<!-- {docsify-ignore} -->` and `<!-- {docsify-ignore-all} -->` will not be rendered on the page when used.
Both `{docsify-ignore}` and `{docsify-ignore-all}` will not be rendered on the page when used.
8 changes: 4 additions & 4 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,14 @@ export class Compiler {
let { str, config } = getAndRemoveConfig(text);
const nextToc = { level, title: str };

if (/<!-- {docsify-ignore} -->/g.test(str)) {
str = str.replace('<!-- {docsify-ignore} -->', '');
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} -->', '');
if (/{docsify-ignore-all}/g.test(str)) {
str = str.replace('{docsify-ignore-all}', '');
nextToc.title = str;
nextToc.ignoreAllSubs = true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/render/compiler/headline.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ export const headingCompiler = ({ renderer, router, _self }) =>
let { str, config } = getAndRemoveConfig(text);
const nextToc = { level, title: str };

if (/<!-- {docsify-ignore} -->/g.test(str)) {
str = str.replace('<!-- {docsify-ignore} -->', '');
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} -->', '');
if (/{docsify-ignore-all}/g.test(str)) {
str = str.replace('{docsify-ignore-all}', '');
nextToc.title = str;
nextToc.ignoreAllSubs = true;
}
Expand Down
6 changes: 2 additions & 4 deletions test/unit/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
`
Expand All @@ -271,7 +269,7 @@ describe('render', function() {
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,
Expand Down

0 comments on commit 8b7dbaa

Please sign in to comment.