Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce31607

Browse files
authored
fix : add patch for {docsify-ignore} and {docsify-ignore-all} (#1351)
* revert: Convert {docsify-ignore} and {docsify-ignore-all} to HTML commentsThis reverts commit90d283d* fix: patch for docsify-ignore* fix test* fix test
1 parentef32da1 commitce31607

File tree

3 files changed

+63
-4
lines changed

3 files changed

+63
-4
lines changed

‎src/core/render/compiler.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,24 @@ export class Compiler {
214214
nextToc.ignoreSubHeading=true;
215215
}
216216

217+
if(/{docsify-ignore}/g.test(str)){
218+
str=str.replace('{docsify-ignore}','');
219+
nextToc.title=str;
220+
nextToc.ignoreSubHeading=true;
221+
}
222+
217223
if(/<!--{docsify-ignore-all}-->/g.test(str)){
218224
str=str.replace('<!-- {docsify-ignore-all} -->','');
219225
nextToc.title=str;
220226
nextToc.ignoreAllSubs=true;
221227
}
222228

229+
if(/{docsify-ignore-all}/g.test(str)){
230+
str=str.replace('{docsify-ignore-all}','');
231+
nextToc.title=str;
232+
nextToc.ignoreAllSubs=true;
233+
}
234+
223235
constslug=slugify(config.id||str);
224236
consturl=router.toURL(router.getCurrentPath(),{id:slug});
225237
nextToc.slug=url;

‎src/core/render/compiler/headline.js‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,24 @@ export const headingCompiler = ({ renderer, router, _self }) =>
1212
nextToc.ignoreSubHeading=true;
1313
}
1414

15+
if(/{docsify-ignore}/g.test(str)){
16+
str=str.replace('{docsify-ignore}','');
17+
nextToc.title=str;
18+
nextToc.ignoreSubHeading=true;
19+
}
20+
1521
if(/<!--{docsify-ignore-all}-->/g.test(str)){
1622
str=str.replace('<!-- {docsify-ignore-all} -->','');
1723
nextToc.title=str;
1824
nextToc.ignoreAllSubs=true;
1925
}
2026

27+
if(/{docsify-ignore-all}/g.test(str)){
28+
str=str.replace('{docsify-ignore-all}','');
29+
nextToc.title=str;
30+
nextToc.ignoreAllSubs=true;
31+
}
32+
2133
constslug=slugify(config.id||str);
2234
consturl=router.toURL(router.getCurrentPath(),{id:slug});
2335
nextToc.slug=url;

‎test/unit/render.test.js‎

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

255255
it('ignore',asyncfunction(){
256256
const{ docsify}=awaitinit();
257-
constoutput=docsify.compiler.compile(
258-
'## h2 tag <!-- {docsify-ignore} -->'
259-
);
257+
constoutput=docsify.compiler.compile('## h2 tag {docsify-ignore}');
260258
expectSameDom(
261259
output,
262260
`
@@ -268,10 +266,26 @@ describe('render', function() {
268266
);
269267
});
270268

269+
it('ignore-html-comments',asyncfunction(){
270+
const{ docsify}=awaitinit();
271+
constoutput=docsify.compiler.compile(
272+
'## h2 tag ignore <!-- {docsify-ignore} -->'
273+
);
274+
expectSameDom(
275+
output,
276+
`
277+
<h2 id="h2-tag-ignore">
278+
<a href="#/?id=h2-tag-ignore" data-id="h2-tag-ignore" class="anchor">
279+
<span>h2 tag ignore </span>
280+
</a>
281+
</h2>`
282+
);
283+
});
284+
271285
it('ignore-all',asyncfunction(){
272286
const{ docsify}=awaitinit();
273287
constoutput=docsify.compiler.compile(
274-
`# h1 tag<!--{docsify-ignore-all} -->`+`\n## h2 tag`
288+
`# h1 tag {docsify-ignore-all}`+`\n## h2 tag`
275289
);
276290
expectSameDom(
277291
output,
@@ -288,6 +302,27 @@ describe('render', function() {
288302
</h2>`
289303
);
290304
});
305+
306+
it('ignore-all-html-comments',asyncfunction(){
307+
const{ docsify}=awaitinit();
308+
constoutput=docsify.compiler.compile(
309+
`# h1 tag ignore <!-- {docsify-ignore-all} -->`+`\n## h2 tag`
310+
);
311+
expectSameDom(
312+
output,
313+
`
314+
<h1 id="h1-tag-ignore">
315+
<a href="#/?id=h1-tag-ignore" data-id="h1-tag-ignore" class="anchor">
316+
<span>h1 tag ignore </span>
317+
</a>
318+
</h1>
319+
<h2 id="h2-tag">
320+
<a href="#/?id=h2-tag" data-id="h2-tag" class="anchor">
321+
<span>h2 tag</span>
322+
</a>
323+
</h2>`
324+
);
325+
});
291326
});
292327

293328
describe('link',function(){

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp