Skip to content

Commit

Permalink
Fixed parsing of [a*b**c*]
Browse files Browse the repository at this point in the history
  • Loading branch information
Knagis committed Jun 26, 2015
1 parent 1dc44e8 commit 296a5ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CommonMark/Parser/InlineMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ internal static int MatchInlineStack(InlineStack opener, Subject subj, int closi
inl.FirstChild = inl.NextSibling;
inl.NextSibling = null;

InlineStack.RemoveStackEntry(opener, subj, closer);
InlineStack.RemoveStackEntry(opener, subj, closer?.Previous);
}
else
{
Expand Down Expand Up @@ -354,6 +354,7 @@ internal static int MatchInlineStack(InlineStack opener, Subject subj, int closi
var newCloserInline = new Inline(clInl.LiteralContent.Substring(useDelims));
newCloserInline.SourcePosition = inl.SourceLastPosition = clInl.SourcePosition + useDelims;
newCloserInline.SourceLength = closer.DelimeterCount;
newCloserInline.NextSibling = clInl.NextSibling;

clInl.LiteralContent = null;
clInl.NextSibling = null;
Expand Down
5 changes: 3 additions & 2 deletions CommonMark/Parser/InlineStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ public static void RemoveStackEntry(InlineStack first, Subject subj, InlineStack
// handle case like [*b*] (the whole [..] is being removed but the inner *..* must still be matched).
// this is not done automatically because the initial * is recognized as a potential closer (assuming
// potential scenario '*[*' ).
PostProcessInlineStack(null, first, last, curPriority);
if (curPriority > 0)
PostProcessInlineStack(null, first, last, curPriority);
}

public static void PostProcessInlineStack(Subject subj, InlineStack first, InlineStack last, InlineStackPriority ignorePriority)
Expand Down Expand Up @@ -198,7 +199,7 @@ public static void PostProcessInlineStack(Subject subj, InlineStack first, Inlin
if (retry)
{
// remove everything between opened and closer (not inclusive).
if (iopener.Next != istack.Previous)
if (istack.Previous != null && iopener.Next != istack.Previous)
RemoveStackEntry(iopener.Next, subj, istack.Previous);

continue;
Expand Down

0 comments on commit 296a5ad

Please sign in to comment.