From b0a91ceec2ddbec19740cd1653ed4924cfe1f543 Mon Sep 17 00:00:00 2001 From: marihachi Date: Sat, 26 Jun 2021 22:18:18 +0900 Subject: [PATCH] Resolve #64 --- src/internal/parser.pegjs | 9 +++++---- src/internal/util.ts | 4 ++++ 2 files changed, 9 insertions(+), 4 deletions(-) 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);