Skip to content

Commit aa53b9a

Browse files
committed
Format
1 parent 3050c5c commit aa53b9a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/Elastic.Markdown/Myst/MarkdownParser.cs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// See the LICENSE file in the project root for more information
44

55
using System.IO.Abstractions;
6+
using System.Text.RegularExpressions;
7+
68
using Cysharp.IO;
9+
710
using Elastic.Documentation.Diagnostics;
8-
using System.Text.RegularExpressions;
911
using Elastic.Markdown.Myst.CodeBlocks;
1012
using Elastic.Markdown.Myst.Comments;
1113
using Elastic.Markdown.Myst.Directives;
@@ -15,6 +17,7 @@
1517
using Elastic.Markdown.Myst.Renderers;
1618
using Elastic.Markdown.Myst.Roles;
1719
using Elastic.Markdown.Myst.Roles.AppliesTo;
20+
1821
using Markdig;
1922
using Markdig.Extensions.EmphasisExtras;
2023
using Markdig.Parsers;
@@ -28,7 +31,8 @@ public class MarkdownParser(BuildContext build, IParserResolvers resolvers)
2831
private IParserResolvers Resolvers { get; } = resolvers;
2932

3033
// Collection of irregular whitespace characters that may impair Markdown rendering
31-
private static readonly char[] IrregularWhitespaceChars = {
34+
private static readonly char[] IrregularWhitespaceChars =
35+
[
3236
'\u000B', // Line Tabulation (\v) - <VT>
3337
'\u000C', // Form Feed (\f) - <FF>
3438
'\u00A0', // No-Break Space - <NBSP>
@@ -53,13 +57,13 @@ public class MarkdownParser(BuildContext build, IParserResolvers resolvers)
5357
'\u202F', // Narrow No-Break Space
5458
'\u205F', // Medium Mathematical Space
5559
'\u3000' // Ideographic Space
56-
};
60+
];
5761

5862
// Detects irregular whitespace in the markdown content and reports diagnostics
5963
private void DetectIrregularWhitespace(string content, string filePath)
6064
{
61-
var lines = content.Split(new[] { "\r\n", "\n", "\r" }, StringSplitOptions.None);
62-
65+
var lines = content.Split(["\r\n", "\n", "\r"], StringSplitOptions.None);
66+
6367
for (var lineIndex = 0; lineIndex < lines.Length; lineIndex++)
6468
{
6569
var line = lines[lineIndex];
@@ -82,7 +86,7 @@ private void DetectIrregularWhitespace(string content, string filePath)
8286
}
8387
}
8488
}
85-
89+
8690
// Helper to get a friendly name for the whitespace character
8791
private static string GetCharacterName(char c) => c switch
8892
{
@@ -113,6 +117,7 @@ private void DetectIrregularWhitespace(string content, string filePath)
113117
_ => "Unknown"
114118
};
115119

120+
116121
public Task<MarkdownDocument> MinimalParseAsync(IFileInfo path, Cancel ctx)
117122
{
118123
var state = new ParserState(Build)
@@ -197,10 +202,10 @@ private async Task<MarkdownDocument> ParseAsync(
197202
{
198203
inputMarkdown = await path.FileSystem.File.ReadAllTextAsync(path.FullName, ctx);
199204
}
200-
205+
201206
// Check for irregular whitespace characters
202207
DetectIrregularWhitespace(inputMarkdown, path.FullName);
203-
208+
204209
var markdownDocument = Markdig.Markdown.Parse(inputMarkdown, pipeline, context);
205210
return markdownDocument;
206211
}

0 commit comments

Comments
 (0)