Skip to content

Commit bfedead

Browse files
committed
.
1 parent 5398afb commit bfedead

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

src/MarkdownSnippets/MissingSnippetsException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static string Report(IReadOnlyList<MissingSnippet> missing) =>
99
string.Join(
1010
$"{Environment.NewLine} ",
1111
missing.GroupBy(_ => _.File ?? "file-unknown")
12-
.Select(_ => $"{_.Key}: {string.Join(",", _.Select(s => s.Key))}"));
12+
.Select(_ => $"{_.Key}: {string.Join(',', _.Select(_ => _.Key))}"));
1313

1414
public override string ToString() => Message;
1515
}

src/MarkdownSnippets/Processing/MarkdownProcessor.cs

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void ProcessWebSnippetLine(Action<string> appendLine, List<MissingSnippet> missi
316316
// Extract snippets from content
317317
using var reader = new StringReader(content);
318318
var snippets = FileSnippetExtractor.Read(reader, url);
319-
var found = snippets.FirstOrDefault(s => s.Key == snippetKey);
319+
var found = snippets.FirstOrDefault(_ => _.Key == snippetKey);
320320
if (found == null)
321321
{
322322
var missing = new MissingSnippet($"{url}#{snippetKey}", line.LineNumber, line.Path);
@@ -416,19 +416,9 @@ Snippet FileToSnippet(string key, string file, string? path)
416416

417417
(string text, int lineCount) ReadNonStartEndLines(string file)
418418
{
419-
using var reader = File.OpenText(file);
420-
var lines = new List<string>();
421-
while (reader.ReadLine() is { } line)
422-
{
423-
if (StartEndTester.IsStartOrEnd(line))
424-
{
425-
continue;
426-
}
427-
428-
lines.Add(line);
429-
}
430-
431-
var text = string.Join(newLine, lines).Trim();
432-
return (text, lines.Count);
419+
var cleanedLines = File.ReadAllLines(file)
420+
.Where(_ => !StartEndTester.IsStartOrEnd(_.TrimStart())).ToList();
421+
var text = string.Join(newLine, cleanedLines).Trim();
422+
return (text, cleanedLines.Count);
433423
}
434424
}

0 commit comments

Comments
 (0)