@@ -5,7 +5,11 @@ import { tree as treeTpl } from './tpl';
55import { genTree } from './gen-tree' ;
66import { slugify } from './slugify' ;
77import { emojify } from './emojify' ;
8- import { getAndRemoveConfig , removeAtag } from './utils' ;
8+ import {
9+ getAndRemoveConfig ,
10+ removeAtag ,
11+ getAndRemoveDocisfyIgnorConfig ,
12+ } from './utils' ;
913import { imageCompiler } from './compiler/image' ;
1014import { highlightCodeCompiler } from './compiler/code' ;
1115import { paragraphCompiler } from './compiler/paragraph' ;
@@ -207,32 +211,15 @@ export class Compiler {
207211 */
208212 origin . heading = renderer . heading = function ( text , level ) {
209213 let { str, config } = getAndRemoveConfig ( text ) ;
210- const nextToc = { level, title : removeAtag ( str ) } ;
214+ const nextToc = { level, title : str } ;
211215
212- if ( / < ! - - { docsify-i g n o r e } - - > / g. test ( str ) ) {
213- str = str . replace ( '<!-- {docsify-ignore} -->' , '' ) ;
214- nextToc . title = removeAtag ( str ) ;
215- nextToc . ignoreSubHeading = true ;
216- }
217-
218- if ( / { d o c s i f y - i g n o r e } / g. test ( str ) ) {
219- str = str . replace ( '{docsify-ignore}' , '' ) ;
220- nextToc . title = removeAtag ( str ) ;
221- nextToc . ignoreSubHeading = true ;
222- }
223-
224- if ( / < ! - - { docsify-i g n o r e - a l l } - - > / g. test ( str ) ) {
225- str = str . replace ( '<!-- {docsify-ignore-all} -->' , '' ) ;
226- nextToc . title = removeAtag ( str ) ;
227- nextToc . ignoreAllSubs = true ;
228- }
229-
230- if ( / { d o c s i f y - i g n o r e - a l l } / g. test ( str ) ) {
231- str = str . replace ( '{docsify-ignore-all}' , '' ) ;
232- nextToc . title = removeAtag ( str ) ;
233- nextToc . ignoreAllSubs = true ;
234- }
216+ const { content, ignoreAllSubs, ignoreSubHeading } =
217+ getAndRemoveDocisfyIgnorConfig ( str ) ;
218+ str = content . trim ( ) ;
235219
220+ nextToc . title = removeAtag ( str ) ;
221+ nextToc . ignoreAllSubs = ignoreAllSubs ;
222+ nextToc . ignoreSubHeading = ignoreSubHeading ;
236223 const slug = slugify ( config . id || str ) ;
237224 const url = router . toURL ( router . getCurrentPath ( ) , { id : slug } ) ;
238225 nextToc . slug = url ;
0 commit comments