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
{{ message }}
Repository navigation
Bold/Strong text not parsed correctly when ending with punctuation followed by CJK characters #454
I've implemented a workaround in my project using mdc.config.ts. Since remark plugins run after micromark has already parsed the markdown into AST, modifying file.value at that stage has no effect.
My solution is to post-process the AST and find unprocessed **...** patterns that remain as text nodes (instead of being converted to strong nodes), then manually convert them.
Here's the workaround:
// mdc.config.tsimporttype{Parent,Root,Text}from'mdast'import{defineConfig}from'@nuxtjs/mdc/config'import{SKIP,visit}from'unist-util-visit'constboldPattern=/\*\*([^*]+)\*\*/gfunctionremarkFixCjkEmphasis(){return(tree: Root)=>{visit(tree,'text',(node: Text,index,parent: Parent|undefined)=>{if(!parent||index===undefined)returnconsttext=node.value// Quick check: skip if no ** at allif(!text.includes('**'))returnconstmatches=[...text.matchAll(boldPattern)]if(matches.length===0)return// Build new nodes arrayconstnewNodes: (Text|{type: 'strong',children: Text[]})[]=[]letlastIndex=0for(constmatchofmatches){constmatchStart=match.index!constmatchEnd=matchStart+match[0].lengthconstboldContent=match[1]// Text before the matchif(matchStart>lastIndex){newNodes.push({type: 'text',value: text.slice(lastIndex,matchStart)}asText)}// The strong nodenewNodes.push({type: 'strong',children: [{type: 'text',value: boldContent}asText],})lastIndex=matchEnd}// Text after the last matchif(lastIndex<text.length){newNodes.push({type: 'text',value: text.slice(lastIndex)}asText)}// Replace the original node with new nodesparent.children.splice(index,1, ...newNodesasnever[])returnSKIP})}}exportdefaultdefineConfig({unified: {remark(processor){returnprocessor.use(remarkFixCjkEmphasis)},},})
This works because:
Only text nodes are processed (code blocks become code nodes, so they're safe)
Failed emphasis parsing leaves **...** as raw text in text nodes
Successfully parsed emphasis becomes strong nodes and won't be affected
This is a temporary workaround. A proper fix would need to be in micromark's attention parsing logic.
Activity
Red-Asuka commentedon Jan 8, 2026
I've implemented a workaround in my project using
mdc.config.ts. Since remark plugins run after micromark has already parsed the markdown into AST, modifyingfile.valueat that stage has no effect.My solution is to post-process the AST and find unprocessed
**...**patterns that remain astextnodes (instead of being converted tostrongnodes), then manually convert them.Here's the workaround:
This works because:
textnodes are processed (code blocks becomecodenodes, so they're safe)**...**as raw text intextnodesstrongnodes and won't be affectedThis is a temporary workaround. A proper fix would need to be in micromark's attention parsing logic.