({ renderer, router, _self })
| 2 | import { slugify } from './slugify'; |
| 3 | |
| 4 | export const headingCompiler = ({ renderer, router, _self }) => |
| 5 | (renderer.code = (text, level) => { |
| 6 | let { str, config } = getAndRemoveConfig(text); |
| 7 | const nextToc = { level, title: removeAtag(str) }; |
| 8 | |
| 9 | if (/<!-- {docsify-ignore} -->/g.test(str)) { |
| 10 | str = str.replace('<!-- {docsify-ignore} -->', ''); |
| 11 | nextToc.title = removeAtag(str); |
| 12 | nextToc.ignoreSubHeading = true; |
| 13 | } |
| 14 | |
| 15 | if (/{docsify-ignore}/g.test(str)) { |
| 16 | str = str.replace('{docsify-ignore}', ''); |
| 17 | nextToc.title = removeAtag(str); |
| 18 | nextToc.ignoreSubHeading = true; |
| 19 | } |
| 20 | |
| 21 | if (/<!-- {docsify-ignore-all} -->/g.test(str)) { |
| 22 | str = str.replace('<!-- {docsify-ignore-all} -->', ''); |
| 23 | nextToc.title = removeAtag(str); |
| 24 | nextToc.ignoreAllSubs = true; |
| 25 | } |
| 26 | |
| 27 | if (/{docsify-ignore-all}/g.test(str)) { |
| 28 | str = str.replace('{docsify-ignore-all}', ''); |
| 29 | nextToc.title = removeAtag(str); |
| 30 | nextToc.ignoreAllSubs = true; |
| 31 | } |
| 32 | |
| 33 | const slug = slugify(config.id || str); |
| 34 | const url = router.toURL(router.getCurrentPath(), { id: slug }); |
| 35 | nextToc.slug = url; |
| 36 | _self.toc.push(nextToc); |
| 37 | |
| 38 | return `<h${level} id="${slug}"><a href="${url}" data-id="${slug}" class="anchor"><span>${str}</span></a></h${level}>`; |
| 39 | }); |
nothing calls this directly
no test coverage detected
searching dependent graphs…