You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used an MD API that can convert MD strings into HTML elements.
I want to use him to manipulate the MD string, what should I do?
I tried using the vite plugin to intercept the received MD string for conversion, but it seems that even after the return, it still needs to be marked down and parsed again.Is there a way for me to directly have vitepress load an HTML elements?
in vite plugin
import{Plugin}from'vite'import{defaultasCherryEngine}from'cherry-markdown/dist/cherry-markdown.engine.core.common';constcherryEngineInstance=newCherryEngine({});exportdefaultfunctionvitePluginVitepressCherryMarkdown(): Plugin{return{name: 'vite-plugin-vitepress-cherry-markdown',transform(code,id){constmatchFiles=Array.from(id.matchAll(/\.md/g));constindexFiles=Array.from(id.matchAll(/index.md/g));if(!matchFiles.length||indexFiles.length)return;//The returned string is an HTML element stringreturncherryEngineInstance.makeHtml(code);},}}
I tried using its function but it still doesn't work,
in .vitepress/config.js
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I used an MD API that can convert MD strings into HTML elements.
I want to use him to manipulate the MD string, what should I do?
in
vite plugin
in
.vitepress/config.js
Beta Was this translation helpful? Give feedback.
All reactions