-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: render code style clean and update (#2477)
- Loading branch information
Showing
8 changed files
with
108 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
getAndRemoveConfig, | ||
removeAtag, | ||
getAndRemoveDocsifyIgnoreConfig, | ||
} from '../utils.js'; | ||
import { slugify } from '../slugify.js'; | ||
|
||
export const headingCompiler = ({ renderer, router, compiler }) => | ||
(renderer.heading = function ({ tokens, depth }) { | ||
const text = this.parser.parseInline(tokens); | ||
let { str, config } = getAndRemoveConfig(text); | ||
const nextToc = { depth, title: str }; | ||
|
||
const { content, ignoreAllSubs, ignoreSubHeading } = | ||
getAndRemoveDocsifyIgnoreConfig(str); | ||
str = content.trim(); | ||
|
||
nextToc.title = removeAtag(str); | ||
nextToc.ignoreAllSubs = ignoreAllSubs; | ||
nextToc.ignoreSubHeading = ignoreSubHeading; | ||
const slug = slugify(config.id || str); | ||
const url = router.toURL(router.getCurrentPath(), { id: slug }); | ||
nextToc.slug = url; | ||
compiler.toc.push(nextToc); | ||
|
||
// Note: tabindex="-1" allows programmatically focusing on heading | ||
// elements after navigation. This is preferred over focusing on the link | ||
// within the heading because it matches the focus behavior of screen | ||
// readers when navigating page content. | ||
return `<h${depth} id="${slug}" tabindex="-1"><a href="${url}" data-id="${slug}" class="anchor"><span>${str}</span></a></h${depth}>`; | ||
}); |
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
export const compileMedia = { | ||
markdown(url) { | ||
return { | ||
url, | ||
}; | ||
}, | ||
mermaid(url) { | ||
return { | ||
url, | ||
}; | ||
}, | ||
iframe(url, title) { | ||
return { | ||
html: `<iframe src="${url}" ${ | ||
title || 'width=100% height=400' | ||
}></iframe>`, | ||
}; | ||
}, | ||
video(url, title) { | ||
return { | ||
html: `<video src="${url}" ${title || 'controls'}>Not Support</video>`, | ||
}; | ||
}, | ||
audio(url, title) { | ||
return { | ||
html: `<audio src="${url}" ${title || 'controls'}>Not Support</audio>`, | ||
}; | ||
}, | ||
code(url, title) { | ||
let lang = url.match(/\.(\w+)$/); | ||
|
||
lang = title || (lang && lang[1]); | ||
if (lang === 'md') { | ||
lang = 'markdown'; | ||
} | ||
|
||
return { | ||
url, | ||
lang, | ||
}; | ||
}, | ||
}; |
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