-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathEnhancedCodeBlock.cs
More file actions
45 lines (31 loc) · 1.39 KB
/
EnhancedCodeBlock.cs
File metadata and controls
45 lines (31 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information
using System.IO.Abstractions;
using Elastic.Documentation.Configuration;
using Elastic.Markdown.Myst.Directives;
using Markdig.Parsers;
using Markdig.Syntax;
namespace Elastic.Markdown.Myst.CodeBlocks;
public class ApiSegment
{
public string Header { get; set; } = "";
public List<string> ContentLines { get; set; } = [];
public int LineNumber { get; set; }
public List<(string Content, int LineNumber)> ContentLinesWithNumbers { get; set; } = [];
}
public class EnhancedCodeBlock(BlockParser parser, ParserContext context)
: FencedCodeBlock(parser), IBlockExtension
{
public BuildContext Build { get; } = context.Build;
public ParserContext Context { get; } = context;
public IFileInfo CurrentFile { get; } = context.MarkdownSourcePath;
public bool SkipValidation { get; } = context.SkipValidation;
public int OpeningLength => Info?.Length ?? (0 + 3);
public List<CallOut> CallOuts { get; set; } = [];
public IReadOnlyCollection<CallOut> UniqueCallOuts => [.. CallOuts.DistinctBy(c => c.Index)];
public bool InlineAnnotations { get; set; }
public string Language { get; set; } = "plaintext";
public string? Caption { get; set; }
public List<ApiSegment> ApiSegments { get; set; } = [];
}