From 795d002ed0e9ff44d68f8a44a80980678c26bfef Mon Sep 17 00:00:00 2001 From: Alexandre Mutel Date: Wed, 8 Jun 2016 16:08:01 +0900 Subject: [PATCH] Fix issue with CodeInlineParser that was incrementing local line index even without matching, resulting in an exception IndexOutOfRange --- src/Markdig/Parsers/Inlines/CodeInlineParser.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Markdig/Parsers/Inlines/CodeInlineParser.cs b/src/Markdig/Parsers/Inlines/CodeInlineParser.cs index d6233fec..f4e56678 100644 --- a/src/Markdig/Parsers/Inlines/CodeInlineParser.cs +++ b/src/Markdig/Parsers/Inlines/CodeInlineParser.cs @@ -47,13 +47,13 @@ namespace Markdig.Parsers.Inlines // The contents of the code span are the characters between the two backtick strings, with leading and trailing spaces and line endings removed, and whitespace collapsed to single spaces. var pc = ' '; + int newLinesFound = 0; while (c != '\0') { // Transform '\n' into a single space if (c == '\n') { - processor.LocalLineIndex++; - processor.LineIndex++; + newLinesFound++; c = ' '; } @@ -104,6 +104,9 @@ namespace Markdig.Parsers.Inlines Content = builder.ToString() }; isMatching = true; + + processor.LocalLineIndex += newLinesFound; + processor.LineIndex += newLinesFound; } // Release the builder if not used