-
Notifications
You must be signed in to change notification settings - Fork 918
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1.Optimize code 2.refresh readme 3.fix toc anchor jump
- Loading branch information
Showing
6 changed files
with
58 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const HEADER_FLAG = ' _MD-HEADER_ '; | ||
|
||
export function headRule(tocHeadRule) { | ||
return function (tokens, index) { | ||
let code = tocHeadRule(tokens, index); | ||
var label = tokens[index + 1]; | ||
if (label.type === 'inline') { | ||
return code.replace('<a', `<a${HEADER_FLAG}`); | ||
} | ||
return code; | ||
}; | ||
} | ||
export function recoverHead(tag, html) { | ||
if (tag === 'a' && html.indexOf(HEADER_FLAG) !== -1) { | ||
return html.replace(HEADER_FLAG, ''); | ||
} | ||
return html; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters