Skip to content
This repository was archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Fix rendering quotes inside spoilers and text effects.
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew4850 committed May 1, 2022
1 parent 0bfe96e commit fee5d0c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/Libs/Quarrel.Markdown/Parsing/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ internal static class Parser
private static Regex textUnicodeRange = new Regex("^(?:\uDB40[\uDC61-\uDC7A])$");


internal static IList<IAST> ParseAST(string text, bool inlineState, bool nested)
internal static IList<IAST> ParseAST(string text, bool inlineState, bool inQuote)
{
List<IAST> collection = new List<IAST>();
while (!string.IsNullOrEmpty(text))
Expand All @@ -64,7 +64,7 @@ internal static IList<IAST> ParseAST(string text, bool inlineState, bool nested)
inline = isAnimated ? new AnimatedEmoji(name, id) : new Emoji(name, id);
text = text.Substring(customEmojiMatch.Length);
}
else if (blockQuote.Match(text) is { Success: true } blockQuoteMatch && !nested)
else if (blockQuote.Match(text) is { Success: true } blockQuoteMatch && !inQuote)
{
string newStr = (codeBlockReplace.IsMatch(blockQuoteMatch.Value) ? codeBlockReplace : codeBlockReplaceSingle).Replace(blockQuoteMatch.Value, "");

Expand All @@ -77,7 +77,7 @@ internal static IList<IAST> ParseAST(string text, bool inlineState, bool nested)
}
else if (paragraph.Match(text) is { Success: true } paragraphMatch && !inlineState)
{
collection.AddRange(ParseAST(paragraphMatch.Groups[1].Value, inlineState, true));
collection.AddRange(ParseAST(paragraphMatch.Groups[1].Value, inlineState, inQuote));
text = text.Substring(paragraphMatch.Length);
}
else if (escape.Match(text) is { Success: true } escapeMatch && inlineState)
Expand All @@ -98,31 +98,31 @@ internal static IList<IAST> ParseAST(string text, bool inlineState, bool nested)
else if (strong.Match(text) is { Success: true } strongMatch && inlineState)
{
var group = strongMatch.Groups[1];
inline = new Strong(ParseAST(group.Value, inlineState, true));
inline = new Strong(ParseAST(group.Value, inlineState, inQuote));
text = text.Substring(strongMatch.Length);
}
else if (em.Match(text) is { Success: true } emMatch && inlineState)
{
var group = emMatch.Groups[1].Success ? emMatch.Groups[1] : emMatch.Groups[2];
inline = new Em(ParseAST(group.Value, inlineState, true));
inline = new Em(ParseAST(group.Value, inlineState, inQuote));
text = text.Substring(emMatch.Length);
}
else if (u.Match(text) is { Success: true } uMatch && inlineState)
{
var group = uMatch.Groups[1];
inline = new U(ParseAST(group.Value, inlineState, true));
inline = new U(ParseAST(group.Value, inlineState, inQuote));
text = text.Substring(uMatch.Length);
}
else if (s.Match(text) is { Success: true } sMatch && inlineState)
{
var group = sMatch.Groups[1];
inline = new S(ParseAST(group.Value, inlineState, true));
inline = new S(ParseAST(group.Value, inlineState, inQuote));
text = text.Substring(sMatch.Length);
}
else if (looseEm.Match(text) is { Success: true } looseEmMatch && inlineState)
{
var group = looseEmMatch.Groups[1];
inline = new Em(ParseAST(group.Value, inlineState, true));
inline = new Em(ParseAST(group.Value, inlineState, inQuote));
text = text.Substring(looseEmMatch.Length);
}
else if (inlineCode.Match(text) is { Success: true } inlineCodeMatch && inlineState)
Expand Down Expand Up @@ -171,7 +171,7 @@ internal static IList<IAST> ParseAST(string text, bool inlineState, bool nested)
}
else if (spoiler.Match(text) is { Success: true } spoilerMatch)
{
inline = new Spoiler(ParseAST(spoilerMatch.Groups[1].Value, inlineState, true));
inline = new Spoiler(ParseAST(spoilerMatch.Groups[1].Value, inlineState, inQuote));
text = text.Substring(spoilerMatch.Length);
}
else if (Parser.text.Match(text) is { Success: true } textMatch)
Expand Down

0 comments on commit fee5d0c

Please sign in to comment.