Skip to content

Commit

Permalink
Merge pull request #41 from Ellerbach/mtirion/fix-doclinkchecker-try2
Browse files Browse the repository at this point in the history
Fix the length error in DocLinkChecker
  • Loading branch information
mtirionMSFT authored Nov 6, 2023
2 parents eb3eb98 + 2cf7c47 commit eeaf2fe
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/DocLinkChecker/DocLinkChecker/Helpers/MarkdownHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,23 @@ private static (PipeTable table, List<MarkdownError> errors)
start--;
}

len = markdown.IndexOf('\r', start) - start;
line = markdown.Substring(start, len);
if (markdown.IndexOf('\r') >= 0)
{
len = markdown.IndexOf('\r', start) - start;
}
else if (markdown.IndexOf('\n') >= 0)
{
len = markdown.IndexOf('\n', start) - start;
}

if (len > 0)
{
line = markdown.Substring(start, len);
}
}
catch (Exception ex)
{
Console.WriteLine($"PipeTable error {ex.Message}.\nfilepath: {markdownFilePath}\nmarkdown: {markdown.Substring(0, 40)}...\nTable: line={table.Line} col={table.Column} start={table.Span.Start}");
Console.WriteLine($"PipeTable error\nPATH: {markdownFilePath} MD: {markdown.Substring(0, 10)}... TABLE: line={table.Line} col={table.Column} start={table.Span.Start}\n{ex}");
}

int row = 0;
Expand Down

0 comments on commit eeaf2fe

Please sign in to comment.