Skip to content

Commit

Permalink
Merge pull request #40 from Ellerbach/doclinkchecker/fix-orphaned-res…
Browse files Browse the repository at this point in the history
…ources-validation

Fix orphaned resources validation.
  • Loading branch information
mtirionMSFT authored Nov 2, 2023
2 parents 0cc5252 + 1d1474c commit eb3eb98
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
27 changes: 20 additions & 7 deletions src/DocLinkChecker/DocLinkChecker/Helpers/MarkdownHelper.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace DocLinkChecker.Helpers
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
Expand Down Expand Up @@ -220,17 +221,29 @@ private static (PipeTable table, List<MarkdownError> errors)
private static (PipeTable table, List<MarkdownError> errors)
ValidatePipeTableWithText(string markdownFilePath, string markdown, Table table)
{
PipeTable pipeTable = new (markdownFilePath, table.Line, table.Column);
PipeTable pipeTable = null;
int start = 0;
int len = 0;
string line = string.Empty;
List<MarkdownError> errors = new ();

int start = table.Span.Start;
while (start > 0 && markdown.Substring(start, 1) != "\n")
try
{
start--;
}
pipeTable = new (markdownFilePath, table.Line, table.Column);

start = Math.Max(table.Span.Start, 0);
while (start > 0 && markdown.Substring(start, 1) != "\n")
{
start--;
}

int len = markdown.IndexOf('\r', start) - start;
string line = markdown.Substring(start, len);
len = markdown.IndexOf('\r', start) - start;
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}");
}

int row = 0;
int nrCols = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public ResourceValidatorService(
orphanedResources.Add(resourceFullPath);
errors.Add(
new MarkdownError(
_fileService.GetRelativePath(resourceFullPath, _config.DocumentationFiles.SourceFolder),
_fileService.GetRelativePath(_config.DocumentationFiles.SourceFolder, resourceFullPath),
0,
0,
MarkdownErrorSeverity.Error,
Expand Down

0 comments on commit eb3eb98

Please sign in to comment.