Skip to content

Commit

Permalink
Use collection expressions (part 2)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcarbon committed Dec 14, 2023
1 parent cc76239 commit 8a88fd0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class SmartyPantsInlineParser : InlineParser, IPostInlineProcessor
/// </summary>
public SmartyPantsInlineParser()
{
OpeningCharacters = new[] {'\'', '"', '<', '>', '.', '-'};
OpeningCharacters = ['\'', '"', '<', '>', '.', '-'];
}

public override bool Match(InlineProcessor processor, ref StringSlice slice)
Expand Down
10 changes: 5 additions & 5 deletions src/Markdig/Extensions/Tables/PipeTableParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public class PipeTableParser : InlineParser, IPostInlineProcessor
/// <summary>
/// Initializes a new instance of the <see cref="PipeTableParser" /> class.
/// </summary>
/// <param name="lineBreakParser">The linebreak parser to use</param>
/// <param name="lineBreakParser">The line break parser to use</param>
/// <param name="options">The options.</param>
public PipeTableParser(LineBreakInlineParser lineBreakParser, PipeTableOptions? options = null)
{
this.lineBreakParser = lineBreakParser ?? throw new ArgumentNullException(nameof(lineBreakParser));
OpeningCharacters = new[] { '|', '\n', '\r' };
OpeningCharacters = ['|', '\n', '\r'];
Options = options ?? new PipeTableOptions();
}

Expand Down Expand Up @@ -637,10 +637,10 @@ private sealed class TableState

public int LineIndex { get; set; }

public List<Inline> ColumnAndLineDelimiters { get; } = new();
public List<Inline> ColumnAndLineDelimiters { get; } = [];

public List<TableCell> Cells { get; } = new();
public List<TableCell> Cells { get; } = [];

public List<Inline> EndOfLines { get; } = new();
public List<Inline> EndOfLines { get; } = [];
}
}
2 changes: 1 addition & 1 deletion src/Markdig/Helpers/CharacterMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public CharacterMap(IEnumerable<KeyValuePair<char, T>> maps)
charSet.Add(map.Key);
}

OpeningCharacters = charSet.ToArray();
OpeningCharacters = [.. charSet];
Array.Sort(OpeningCharacters);

_asciiMap = new T[128];
Expand Down
12 changes: 6 additions & 6 deletions src/Markdig/MarkdownPipelineBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public class MarkdownPipelineBuilder
public MarkdownPipelineBuilder()
{
// Add all default parsers
BlockParsers = new OrderedList<BlockParser>()
{
BlockParsers =
[
new ThematicBreakParser(),
new HeadingBlockParser(),
new QuoteBlockParser(),
Expand All @@ -35,18 +35,18 @@ public MarkdownPipelineBuilder()
new FencedCodeBlockParser(),
new IndentedCodeBlockParser(),
new ParagraphBlockParser(),
};
];

InlineParsers = new OrderedList<InlineParser>()
{
InlineParsers =
[
new HtmlEntityParser(),
new LinkInlineParser(),
new EscapeInlineParser(),
new EmphasisInlineParser(),
new CodeInlineParser(),
new AutolinkInlineParser(),
new LineBreakInlineParser(),
};
];

Extensions = new OrderedList<IMarkdownExtension>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Markdig/Parsers/BlockProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public Block? NextContinue
/// <summary>
/// Gets the current stack of <see cref="Block"/> being processed.
/// </summary>
private List<BlockWrapper> OpenedBlocks { get; } = new();
private List<BlockWrapper> OpenedBlocks { get; } = [];

private bool ContinueProcessingLine { get; set; }

Expand Down
4 changes: 2 additions & 2 deletions src/Markdig/Parsers/ThematicBreakParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class ThematicBreakParser : BlockParser
/// <summary>
/// A singleton instance used by other parsers.
/// </summary>
public static readonly ThematicBreakParser Default = new ThematicBreakParser();
public static readonly ThematicBreakParser Default = new();

/// <summary>
/// Initializes a new instance of the <see cref="ThematicBreakParser"/> class.
/// </summary>
public ThematicBreakParser()
{
OpeningCharacters = new[] {'-', '_', '*'};
OpeningCharacters = ['-', '_', '*'];
}

public override BlockState TryOpen(BlockProcessor processor)
Expand Down

0 comments on commit 8a88fd0

Please sign in to comment.