mirror of
https://github.com/xoofx/markdig.git
synced 2026-02-04 05:44:50 +00:00
Use collection expressions
This commit is contained in:
@@ -20,7 +20,7 @@ public class AbbreviationParser : BlockParser
|
||||
/// </summary>
|
||||
public AbbreviationParser()
|
||||
{
|
||||
OpeningCharacters = new[] { '*' };
|
||||
OpeningCharacters = ['*'];
|
||||
}
|
||||
|
||||
public override BlockState TryOpen(BlockProcessor processor)
|
||||
|
||||
@@ -1786,6 +1786,6 @@ public class EmojiMapping
|
||||
ThrowHelper.ArgumentException(string.Format("Smiley {0} is already present in the emoji mapping", smiley.Key));
|
||||
}
|
||||
|
||||
OpeningCharacters = new List<char>(firstChars).ToArray();
|
||||
OpeningCharacters = [.. firstChars];
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ public class FigureBlockParser : BlockParser
|
||||
/// </summary>
|
||||
public FigureBlockParser()
|
||||
{
|
||||
OpeningCharacters = new[] { '^' };
|
||||
OpeningCharacters = ['^'];
|
||||
}
|
||||
|
||||
public override BlockState TryOpen(BlockProcessor processor)
|
||||
|
||||
@@ -19,7 +19,7 @@ public class FooterBlockParser : BlockParser
|
||||
/// </summary>
|
||||
public FooterBlockParser()
|
||||
{
|
||||
OpeningCharacters = new[] {'^'};
|
||||
OpeningCharacters = ['^'];
|
||||
}
|
||||
|
||||
public override BlockState TryOpen(BlockProcessor processor)
|
||||
|
||||
@@ -23,7 +23,7 @@ public class GenericAttributesParser : InlineParser
|
||||
/// </summary>
|
||||
public GenericAttributesParser()
|
||||
{
|
||||
OpeningCharacters = new[] { '{' };
|
||||
OpeningCharacters = ['{'];
|
||||
}
|
||||
|
||||
public override bool Match(InlineProcessor processor, ref StringSlice slice)
|
||||
@@ -136,10 +136,7 @@ public class GenericAttributesParser : InlineParser
|
||||
var text = slice.Text.Substring(start, end - start + 1);
|
||||
if (isClass)
|
||||
{
|
||||
if (classes is null)
|
||||
{
|
||||
classes = new List<string>();
|
||||
}
|
||||
classes ??= new List<string>();
|
||||
classes.Add(text);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -21,7 +21,7 @@ public class MathInlineParser : InlineParser
|
||||
/// </summary>
|
||||
public MathInlineParser()
|
||||
{
|
||||
OpeningCharacters = new[] { '$' };
|
||||
OpeningCharacters = ['$'];
|
||||
DefaultClass = "math";
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public class NoFollowLinksExtension : IMarkdownExtension
|
||||
|
||||
public NoFollowLinksExtension()
|
||||
{
|
||||
_referralLinksExtension = new ReferralLinksExtension(new[] { "nofollow" });
|
||||
_referralLinksExtension = new ReferralLinksExtension(["nofollow"]);
|
||||
}
|
||||
|
||||
public void Setup(MarkdownPipelineBuilder pipeline)
|
||||
|
||||
@@ -12,7 +12,7 @@ public class GridTableParser : BlockParser
|
||||
{
|
||||
public GridTableParser()
|
||||
{
|
||||
OpeningCharacters = new[] { '+' };
|
||||
OpeningCharacters = ['+'];
|
||||
}
|
||||
|
||||
public override BlockState TryOpen(BlockProcessor processor)
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PipeTableBlockParser : BlockParser
|
||||
/// </summary>
|
||||
public PipeTableBlockParser()
|
||||
{
|
||||
OpeningCharacters = new[] {'-'};
|
||||
OpeningCharacters = ['-'];
|
||||
}
|
||||
|
||||
public override BlockState TryOpen(BlockProcessor processor)
|
||||
|
||||
@@ -19,7 +19,7 @@ public class TaskListInlineParser : InlineParser
|
||||
/// </summary>
|
||||
public TaskListInlineParser()
|
||||
{
|
||||
OpeningCharacters = new[] {'['};
|
||||
OpeningCharacters = ['['];
|
||||
ListClass = "contains-task-list";
|
||||
ListItemClass = "task-list-item";
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class HeadingBlockParser : BlockParser, IAttributesParseable
|
||||
/// </summary>
|
||||
public HeadingBlockParser()
|
||||
{
|
||||
OpeningCharacters = new[] {'#'};
|
||||
OpeningCharacters = ['#'];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -18,7 +18,7 @@ public class HtmlBlockParser : BlockParser
|
||||
/// </summary>
|
||||
public HtmlBlockParser()
|
||||
{
|
||||
OpeningCharacters = new[] { '<' };
|
||||
OpeningCharacters = ['<'];
|
||||
}
|
||||
|
||||
public override BlockState TryOpen(BlockProcessor processor)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Markdig.Parsers.Inlines;
|
||||
public class EmphasisInlineParser : InlineParser, IPostInlineProcessor
|
||||
{
|
||||
private CharacterMap<EmphasisDescriptor>? emphasisMap;
|
||||
private readonly DelimitersObjectCache inlinesCache = new DelimitersObjectCache();
|
||||
private readonly DelimitersObjectCache inlinesCache = new();
|
||||
|
||||
[Obsolete("Use TryCreateEmphasisInlineDelegate instead", error: false)]
|
||||
public delegate EmphasisInline CreateEmphasisInlineDelegate(char emphasisChar, bool isStrong);
|
||||
@@ -31,11 +31,11 @@ public class EmphasisInlineParser : InlineParser, IPostInlineProcessor
|
||||
/// </summary>
|
||||
public EmphasisInlineParser()
|
||||
{
|
||||
EmphasisDescriptors = new List<EmphasisDescriptor>()
|
||||
{
|
||||
EmphasisDescriptors =
|
||||
[
|
||||
new EmphasisDescriptor('*', 1, 2, true),
|
||||
new EmphasisDescriptor('_', 1, 2, false)
|
||||
};
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,7 +65,7 @@ public class EmphasisInlineParser : InlineParser, IPostInlineProcessor
|
||||
/// </summary>
|
||||
[Obsolete("Use TryCreateEmphasisInlineList instead", error: false)]
|
||||
public CreateEmphasisInlineDelegate? CreateEmphasisInline { get; set; }
|
||||
public readonly List<TryCreateEmphasisInlineDelegate> TryCreateEmphasisInlineList = new List<TryCreateEmphasisInlineDelegate>();
|
||||
public readonly List<TryCreateEmphasisInlineDelegate> TryCreateEmphasisInlineList = [];
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ public class EscapeInlineParser : InlineParser
|
||||
{
|
||||
public EscapeInlineParser()
|
||||
{
|
||||
OpeningCharacters = new[] {'\\'};
|
||||
OpeningCharacters = ['\\'];
|
||||
}
|
||||
|
||||
public override bool Match(InlineProcessor processor, ref StringSlice slice)
|
||||
|
||||
@@ -21,7 +21,7 @@ public class HtmlEntityParser : InlineParser
|
||||
/// </summary>
|
||||
public HtmlEntityParser()
|
||||
{
|
||||
OpeningCharacters = new[] {'&'};
|
||||
OpeningCharacters = ['&'];
|
||||
}
|
||||
|
||||
public static bool TryParse(ref StringSlice slice, [NotNullWhen(true)] out string? literal, out int match)
|
||||
|
||||
@@ -18,7 +18,7 @@ public class LineBreakInlineParser : InlineParser
|
||||
/// </summary>
|
||||
public LineBreakInlineParser()
|
||||
{
|
||||
OpeningCharacters = new[] { '\n', '\r' };
|
||||
OpeningCharacters = ['\n', '\r'];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -19,7 +19,7 @@ public class LinkInlineParser : InlineParser
|
||||
/// </summary>
|
||||
public LinkInlineParser()
|
||||
{
|
||||
OpeningCharacters = new[] {'[', ']', '!'};
|
||||
OpeningCharacters = ['[', ']', '!'];
|
||||
}
|
||||
|
||||
public override bool Match(InlineProcessor processor, ref StringSlice slice)
|
||||
@@ -322,7 +322,7 @@ public class LinkInlineParser : InlineParser
|
||||
|
||||
if (label != null || LinkHelper.TryParseLabelTrivia(ref text, true, out label, out labelSpan))
|
||||
{
|
||||
SourceSpan labelWithTrivia = new SourceSpan(labelSpan.Start, labelSpan.End);
|
||||
var labelWithTrivia = new SourceSpan(labelSpan.Start, labelSpan.End);
|
||||
if (isLabelSpanLocal)
|
||||
{
|
||||
labelSpan = inlineState.GetSourcePositionFromLocalSpan(labelSpan);
|
||||
|
||||
@@ -23,7 +23,7 @@ internal sealed class AllowNullAttribute : Attribute { }
|
||||
#if !NET5_0_OR_GREATER
|
||||
internal sealed class MemberNotNullAttribute : Attribute
|
||||
{
|
||||
public MemberNotNullAttribute(string member) => Members = new[] { member };
|
||||
public MemberNotNullAttribute(string member) => Members = [member];
|
||||
|
||||
public MemberNotNullAttribute(params string[] members) => Members = members;
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CodeBlock : LeafBlock
|
||||
}
|
||||
|
||||
private List<CodeBlockLine>? _codeBlockLines;
|
||||
public List<CodeBlockLine> CodeBlockLines => _codeBlockLines ??= new();
|
||||
public List<CodeBlockLine> CodeBlockLines => _codeBlockLines ??= [];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CodeBlock"/> class.
|
||||
|
||||
@@ -27,7 +27,7 @@ public abstract class ContainerBlock : Block, IList<Block>, IReadOnlyList<Block>
|
||||
/// <param name="parser">The parser used to create this block.</param>
|
||||
protected ContainerBlock(BlockParser? parser) : base(parser)
|
||||
{
|
||||
_children = Array.Empty<BlockWrapper>();
|
||||
_children = [];
|
||||
SetTypeKind(isInline: false, isContainer: true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user