Skip to content

Commit

Permalink
fix(NcRichText): adjust import conditions for rehype-highlight library
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Nov 22, 2024
1 parent 2518c65 commit cc74645
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/components/NcRichText/NcRichText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ const rehypeHighlightLoaded = ref(false)
/**
* Load 'rehype-highlight' library when code block is rendered with `useExtendedMarkdown`
*/
async function importRehypeLibrary() {
async function importRehypeHighlightLibrary() {
const module = await import('rehype-highlight')
rehypeHighlight = module.default
rehypeHighlightLoaded.value = true
Expand Down Expand Up @@ -505,8 +505,10 @@ export default {

if (!tag.startsWith('#')) {
if (this.useExtendedMarkdown && remarkGfmLoaded.value) {
if (tag === 'code' && !rehypeHighlightLoaded.value) {
importRehypeLibrary()
if (tag === 'code'
&& attrs?.attrs?.class?.includes('language')
&& !rehypeHighlightLoaded.value) {
importRehypeHighlightLibrary()
}
let nestedNode = null
if (tag === 'li' && Array.isArray(children)
Expand Down

0 comments on commit cc74645

Please sign in to comment.