From c60ba229b5ba00de6cd818b840870e5b8d401338 Mon Sep 17 00:00:00 2001 From: marihachi Date: Sun, 9 Jan 2022 22:07:49 +0900 Subject: [PATCH] Revert "fix bug of link label parsing" (ignore test) --- src/internal/parser.pegjs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/internal/parser.pegjs b/src/internal/parser.pegjs index 57294af..715e02c 100644 --- a/src/internal/parser.pegjs +++ b/src/internal/parser.pegjs @@ -32,17 +32,9 @@ function applyParser(input, startRule) { let parseFunc = peg$parse; - return parseFunc(input, { - startRule: startRule, - fnNameList: options.fnNameList, - nestLimit: (nestLimit - depth), - }); + return parseFunc(input, startRule ? { startRule } : { }); } - // link - - let isLinkLabel = false; - // emoji const emojiRegex = require('twemoji-parser/dist/lib/regex').default; @@ -363,7 +355,7 @@ mathInline // inline: mention mention - = &{ return !isLinkLabel; } "@" name:mentionName host:("@" @mentionHost)? + = "@" name:mentionName host:("@" @mentionHost)? { return MENTION(name, host, text()); } @@ -405,11 +397,11 @@ hashPairInner // inline: URL url - = &{ return !isLinkLabel; } "<" url:$("http" "s"? "://" (!(">" / _) CHAR)+) ">" + = "<" url:$("http" "s"? "://" (!(">" / _) CHAR)+) ">" { return N_URL(url, true); } - / &{ return !isLinkLabel; } "http" "s"? "://" (&([.,]+ urlContentPart) . / urlContentPart)+ + / "http" "s"? "://" (&([.,]+ urlContentPart) . / urlContentPart)+ { // NOTE: last char is neither "." nor ",". return N_URL(text()); @@ -426,13 +418,13 @@ urlPairInner // inline: link link - = &{ return !isLinkLabel; } silent:"?"? "[" label:linkLabel "](" url:url ")" + = silent:"?"? "[" label:linkLabel "](" url:url ")" { return LINK((silent != null), url.props.url, mergeText(label)); } linkLabel - = &{ isLinkLabel = true; return true; } @(@(!"]" @linkLabelPart)+ &{ isLinkLabel = false; return true; } / &{ isLinkLabel = false; return false; }) + = (!"]" @linkLabelPart)+ linkLabelPart = emojiCode