Skip to content

Commit c685754

Browse files
authored
Merge branch 'develop' into fix-1320
2 parents aacf61f + 9150678 commit c685754

File tree

6 files changed

+54
-17
lines changed

6 files changed

+54
-17
lines changed

Diff for: docs/more-pages.md

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

Diff for: packages/docsify-server-renderer/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var readFileSync = require('fs').readFileSync
1414

1515
// init
1616
var renderer = new Renderer({
17-
template: readFileSync('./docs/index.template.html', 'utf-8').,
17+
template: readFileSync('./docs/index.template.html', 'utf-8'),
1818
config: {
1919
name: 'docsify',
2020
repo: 'docsifyjs/docsify'
@@ -35,12 +35,12 @@ renderer.renderToString(url)
3535
<meta charset="UTF-8">
3636
<title>docsify</title>
3737
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
38-
<link rel="stylesheet" href="//unpkg.com/docsify/themes/buble.css" title="buble" disabled>
38+
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify/themes/vue.css" title="vue">
3939
</head>
4040
<body>
4141
<!--inject-app-->
4242
<!--inject-config-->
43-
<script src="//unpkg.com/docsify/lib/docsify.js"></script>
43+
<script src="//cdn.jsdelivr.net/npm/docsify/lib/docsify.js"></script>
4444
</body>
4545
</html>
4646
```

Diff for: src/core/render/compiler.js

+4-4
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
}

Diff for: src/core/render/compiler/headline.js

+4-4
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
}

Diff for: src/core/router/history/hash.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class HashHistory extends History {
3939
on('click', e => {
4040
const el = e.target.tagName === 'A' ? e.target : e.target.parentNode;
4141

42-
if (el.tagName === 'A' && !/_blank/.test(el.target)) {
42+
if (el && el.tagName === 'A' && !/_blank/.test(el.target)) {
4343
navigating = true;
4444
}
4545
});

Diff for: test/unit/render.test.js

+37
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,43 @@ describe('render', function() {
251251
</h6>`
252252
);
253253
});
254+
255+
it('ignore', async function() {
256+
const { docsify } = await init();
257+
const output = docsify.compiler.compile(
258+
'## h2 tag <!-- {docsify-ignore} -->'
259+
);
260+
expectSameDom(
261+
output,
262+
`
263+
<h2 id="h2-tag">
264+
<a href="#/?id=h2-tag" data-id="h2-tag" class="anchor">
265+
<span>h2 tag </span>
266+
</a>
267+
</h2>`
268+
);
269+
});
270+
271+
it('ignore-all', async function() {
272+
const { docsify } = await init();
273+
const output = docsify.compiler.compile(
274+
`# h1 tag <!-- {docsify-ignore-all} -->` + `\n## h2 tag`
275+
);
276+
expectSameDom(
277+
output,
278+
`
279+
<h1 id="h1-tag">
280+
<a href="#/?id=h1-tag" data-id="h1-tag" class="anchor">
281+
<span>h1 tag </span>
282+
</a>
283+
</h1>
284+
<h2 id="h2-tag">
285+
<a href="#/?id=h2-tag" data-id="h2-tag" class="anchor">
286+
<span>h2 tag</span>
287+
</a>
288+
</h2>`
289+
);
290+
});
254291
});
255292

256293
describe('link', function() {

0 commit comments

Comments
 (0)