diff --git a/src/internal/parser.pegjs b/src/internal/parser.pegjs index 0adce8e..7fc13ef 100644 --- a/src/internal/parser.pegjs +++ b/src/internal/parser.pegjs @@ -401,13 +401,14 @@ link linkLabel = parts:linkLabelPart+ { - return parts; + return parts.flat(); } linkLabelPart - = url { return text(); /* text node */ } - / link { return text(); /* text node */ } - / !"]" n:inline { return n; } + = "[" linkLabelPart* "]" linkLabelPart* &("](" url:linkUrl ")") +{ return applyParser(text(), 'inlineParser'); } + / !"]" n:plain +{ return n; } linkUrl = url { return text(); } diff --git a/src/internal/util.ts b/src/internal/util.ts index 9bfec38..44c1f61 100644 --- a/src/internal/util.ts +++ b/src/internal/util.ts @@ -19,6 +19,10 @@ export function mergeText(nodes: (MfmNode | string)[]): MfmNode[] { // Store the char. storedChars.push(node); } + else if (node.type == 'text') { + // Store the text. + storedChars.push(node.props.text); + } else { generateText(); dest.push(node);