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
Hi! Hitting a wall when it comes to using the afterParse hook.
I'm able to change the value of text nodes, but I'm unable to change the node type, like for example from text to inlineCode, which is defined as just swapping type from text to inlineCode
Getting the same error when I try to do the manipulation during a visit run, which i assumed was related to manipulation during iteration, and when using findAndReplace from mdast-util-find-and-replace
So I figured it might still work during direct reference without any iterators and the likes, but still hitting the wall.
Any help at all would be greatly appreciated!
My goal is to make a plugin to support the Foam format, which means supporting Wiki links like [[ this ]] and [[ this|alias]], as well as inline #tags that links to a common page for example :)
index.md
# Index## Tags
#tag1 #tag2 #tag3
#tag_newline
#tag1
#tag1
## Wiki links[[ 1 |Alias for 1]] (Broken)
[[2 |Alias for 2]] (Broken)
[[3|Alias for 3]] (Valid)
[[ 4|Alias for 4]] (Broken)
✔️ Can change value of a text node
Code
nitroApp.hooks.hook("content:file:afterParse",(file: MarkdownParsedContent)=>{if(!useRuntimeConfig().parse_after)returnif(!file._id.endsWith(".md"))returnif(file.body.children[2]?.children[2]){constlink_node={type: "inlineCode",value: "test"}// Targeting the #tag_newline nodefile.body.children[2].children[2].value="MANIPULATED"}});
[nuxt] [request error] [unhandled] [500] src.replace is not a function
at Object.escapeHtmlComment (./node_modules/@vue/shared/dist/shared.cjs.js:334:14)
at renderVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:720:34)
at renderVNodeChildren (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:759:5)
at ssrRenderSlotInner (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:120:7)
at Module.ssrRenderSlot (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:95:3)
at _sfc_ssrRender (./node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseP.vue:11:25)
at renderComponentSubTree (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:683:9)
at renderComponentVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:631:12)
at renderVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:743:14)
at renderComponentSubTree (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:698:7)
[nuxt] [request error] [unhandled] [500] src.replace is not a function
at Object.escapeHtmlComment (./node_modules/@vue/shared/dist/shared.cjs.js:334:14)
at renderVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:720:34)
at renderVNodeChildren (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:759:5)
at ssrRenderSlotInner (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:120:7)
at Module.ssrRenderSlot (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:95:3)
at _sfc_ssrRender (./node_modules/@nuxtjs/mdc/dist/runtime/components/prose/ProseP.vue:11:25)
at renderComponentSubTree (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:683:9)
at renderComponentVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:631:12)
at renderVNode (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:743:14)
at renderComponentSubTree (./node_modules/@vue/server-renderer/dist/server-renderer.cjs.js:698:7)
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
-
Hi! Hitting a wall when it comes to using the afterParse hook.
I'm able to change the value of text nodes, but I'm unable to change the node type, like for example from text to inlineCode, which is defined as just swapping type from
text
toinlineCode
Getting the same error when I try to do the manipulation during a
visit
run, which i assumed was related to manipulation during iteration, and when usingfindAndReplace
frommdast-util-find-and-replace
So I figured it might still work during direct reference without any iterators and the likes, but still hitting the wall.
Any help at all would be greatly appreciated!
My goal is to make a plugin to support the Foam format, which means supporting Wiki links like [[ this ]] and [[ this|alias]], as well as inline #tags that links to a common page for example :)
index.md
✔️ Can change value of a text node
Code
Output
❎ Unable to change node type to anything else:
Code
Output
Stacktrace
Tsconfig:
Beta Was this translation helpful? Give feedback.
All reactions