Skip to content

Commit fbc97be

Browse files
authored
Remove implemented directives that are not needed (#58)
1 parent 53fd0b2 commit fbc97be

File tree

13 files changed

+18
-348
lines changed

13 files changed

+18
-348
lines changed

src/Elastic.Markdown/Myst/Directives/CardBlock.cs

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/Elastic.Markdown/Myst/Directives/DirectiveBlockParser.cs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@ public DirectiveBlockParser()
5050
{ "exercise", 30 },
5151
{ "solution", 31 },
5252
{ "toctree", 32 },
53+
{ "grid", 26 },
54+
{ "grid-item-card", 26 },
55+
{ "card", 25 },
56+
{ "mermaid", 20 },
57+
{ "aside", 4 },
58+
{ "margin", 4 },
59+
{ "sidebar", 4 },
60+
{ "code-cell", 8 },
61+
62+
5363
}.ToFrozenDictionary();
5464

5565
protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor)
@@ -67,24 +77,17 @@ protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor)
6777
if (info.IndexOf("{") == -1)
6878
return new CodeBlock(this, "raw", _admonitionData);
6979

80+
// TODO alternate lookup .NET 9
81+
var directive = info.ToString().Trim(['{', '}', '`']);
82+
if (_unsupportedBlocks.TryGetValue(directive, out var issueId))
83+
return new UnsupportedDirectiveBlock(this, directive, _admonitionData, issueId);
84+
7085
if (info.IndexOf("{tab-set}") > 0)
7186
return new TabSetBlock(this, _admonitionData);
7287

7388
if (info.IndexOf("{tab-item}") > 0)
7489
return new TabItemBlock(this, _admonitionData);
7590

76-
if (info.IndexOf("{sidebar}") > 0)
77-
return new SideBarBlock(this, _admonitionData);
78-
79-
if (info.IndexOf("{card}") > 0)
80-
return new CardBlock(this, _admonitionData);
81-
82-
if (info.IndexOf("{grid}") > 0)
83-
return new GridBlock(this, _admonitionData);
84-
85-
if (info.IndexOf("{grid-item-card}") > 0)
86-
return new GridItemCardBlock(this, _admonitionData);
87-
8891
if (info.IndexOf("{dropdown}") > 0)
8992
return new DropdownBlock(this, _admonitionData);
9093

@@ -97,6 +100,9 @@ protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor)
97100
if (info.IndexOf("{figure-md}") > 0)
98101
return new FigureBlock(this, _admonitionData, context);
99102

103+
// this is currently listed as unsupported
104+
// leaving the parsing in untill we are confident we don't want this
105+
// for dev-docs
100106
if (info.IndexOf("{mermaid}") > 0)
101107
return new MermaidBlock(this, _admonitionData);
102108

@@ -123,11 +129,6 @@ protected override DirectiveBlock CreateFencedBlock(BlockProcessor processor)
123129
if (info.IndexOf($"{{{code}}}") > 0)
124130
return new CodeBlock(this, code, _admonitionData);
125131
}
126-
// TODO alternate lookup .NET 9
127-
var directive = info.ToString().Trim(['{', '}', '`']);
128-
if (_unsupportedBlocks.TryGetValue(directive, out var issueId))
129-
return new UnsupportedDirectiveBlock(this, directive, _admonitionData, issueId);
130-
131132
return new UnknownDirectiveBlock(this, info.ToString(), _admonitionData);
132133
}
133134

src/Elastic.Markdown/Myst/Directives/DirectiveHtmlRenderer.cs

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,12 @@ protected override void Write(HtmlRenderer renderer, DirectiveBlock directiveBlo
5454
case CodeBlock codeBlock:
5555
WriteCode(renderer, codeBlock);
5656
return;
57-
case SideBarBlock sideBar:
58-
WriteSideBar(renderer, sideBar);
59-
return;
6057
case TabSetBlock tabSet:
6158
WriteTabSet(renderer, tabSet);
6259
return;
6360
case TabItemBlock tabItem:
6461
WriteTabItem(renderer, tabItem);
6562
return;
66-
case CardBlock card:
67-
WriteCard(renderer, card);
68-
return;
69-
case GridBlock grid:
70-
WriteGrid(renderer, grid);
71-
return;
72-
case GridItemCardBlock gridItemCard:
73-
WriteGridItemCard(renderer, gridItemCard);
74-
return;
7563
case LiteralIncludeBlock literalIncludeBlock:
7664
WriteLiteralIncludeBlock(renderer, literalIncludeBlock);
7765
return;
@@ -135,30 +123,6 @@ private void WriteFigure(HtmlRenderer renderer, ImageBlock block)
135123
private void WriteChildren(HtmlRenderer renderer, DirectiveBlock directiveBlock) =>
136124
renderer.WriteChildren(directiveBlock);
137125

138-
private void WriteCard(HtmlRenderer renderer, CardBlock block)
139-
{
140-
var slice = Card.Create(new CardViewModel { Title = block.Title, Link = block.Link });
141-
RenderRazorSlice(slice, renderer, block);
142-
}
143-
144-
private void WriteGrid(HtmlRenderer renderer, GridBlock block)
145-
{
146-
var slice = Grid.Create(new GridViewModel
147-
{
148-
BreakPoint = block.BreakPoint
149-
});
150-
RenderRazorSlice(slice, renderer, block);
151-
}
152-
153-
private void WriteGridItemCard(HtmlRenderer renderer, GridItemCardBlock directiveBlock)
154-
{
155-
var title = directiveBlock.Arguments;
156-
var link = directiveBlock.Properties.GetValueOrDefault("link");
157-
var slice = GridItemCard.Create(new GridItemCardViewModel { Title = title, Link = link });
158-
RenderRazorSlice(slice, renderer, directiveBlock);
159-
}
160-
161-
162126
private void WriteVersion(HtmlRenderer renderer, VersionBlock block)
163127
{
164128
var slice = Slices.Directives.Version.Create(new VersionViewModel
@@ -204,12 +168,6 @@ private void WriteCode(HtmlRenderer renderer, CodeBlock block)
204168
}
205169

206170

207-
private void WriteSideBar(HtmlRenderer renderer, SideBarBlock directiveBlock)
208-
{
209-
var slice = SideBar.Create(new SideBarViewModel());
210-
RenderRazorSlice(slice, renderer, directiveBlock);
211-
}
212-
213171
private void WriteTabSet(HtmlRenderer renderer, TabSetBlock block)
214172
{
215173
var slice = TabSet.Create(new TabSetViewModel());

src/Elastic.Markdown/Myst/Directives/SideBarBlock.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/Elastic.Markdown/Myst/Directives/TabSetBlock.cs

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -36,95 +36,3 @@ public override void FinalizeAndValidate(ParserContext context)
3636
}
3737

3838
}
39-
40-
public class GridResponsive
41-
{
42-
public required int Xs { get; init; }
43-
public required int Sm { get; init; }
44-
public required int Md { get; init; }
45-
public required int Lg { get; init; }
46-
}
47-
public class GridCorners
48-
{
49-
public required int Top { get; init; }
50-
public required int Bottom { get; init; }
51-
public required int Left { get; init; }
52-
public required int Right { get; init; }
53-
}
54-
55-
public class GridBlock(DirectiveBlockParser parser, Dictionary<string, string> properties)
56-
: DirectiveBlock(parser, properties)
57-
{
58-
59-
public GridResponsive BreakPoint { get; set; } = new() { Xs = 1, Sm = 1, Md = 2, Lg = 3 };
60-
61-
/// <summary> Spacing between items. One or four integers (for “xs sm md lg”) between 0 and 5. </summary>
62-
public GridResponsive? Gutter { get; set; }
63-
64-
/// <summary> Outer margin of grid. One (all) or four (top bottom left right) values from: 0, 1, 2, 3, 4, 5, auto. </summary>
65-
public GridCorners? Margin { get; set; }
66-
67-
/// <summary> Inner padding of grid. One (all) or four (top bottom left right) values from: 0, 1, 2, 3, 4, 5. </summary>
68-
public GridCorners? Padding { get; set; }
69-
70-
/// <summary> Create a border around the grid. </summary>
71-
public bool? Outline { get; set; }
72-
73-
/// <summary> Reverse the order of the grid items. </summary>
74-
public bool? Reverse { get; set; }
75-
76-
/// <summary> Additional CSS classes for the grid container element. </summary>
77-
public string? ClassContainer { get; set; }
78-
79-
/// <summary> Additional CSS classes for the grid row element </summary>
80-
public string? ClassRow { get; set; }
81-
82-
83-
public override void FinalizeAndValidate(ParserContext context)
84-
{
85-
//todo we always assume 4 integers
86-
if (!string.IsNullOrEmpty(Arguments))
87-
ParseData(Arguments, (xs, sm, md, lg) => BreakPoint = new() { Xs = xs, Sm = sm, Md = md, Lg = lg });
88-
else
89-
{
90-
//todo invalidate
91-
}
92-
if (Properties.GetValueOrDefault("gutter") is { } gutter)
93-
ParseData(gutter, (xs, sm, md, lg) => Gutter = new() { Xs = xs, Sm = sm, Md = md, Lg = lg });
94-
if (Properties.GetValueOrDefault("margin") is { } margin)
95-
ParseData(margin, (top, bottom, left, right) => Margin = new() { Top = top, Bottom = bottom, Left = left, Right = right });
96-
if (Properties.GetValueOrDefault("padding") is { } padding)
97-
ParseData(padding, (top, bottom, left, right) => Padding = new() { Top = top, Bottom = bottom, Left = left, Right = right });
98-
ParseBool("outline", b => Outline = b);
99-
ParseBool("reverse", b => Reverse = b);
100-
101-
ClassContainer = Properties.GetValueOrDefault("class-container");
102-
ClassRow = Properties.GetValueOrDefault("class-row");
103-
104-
}
105-
106-
private void ParseData(string data, Action<int, int, int, int> setter, bool allowAuto = true)
107-
{
108-
var columns = data.Split(' ')
109-
.Select(t => int.TryParse(t, out var c) ? c : t == "auto" ? -1 : -2)
110-
.Where(t => t is > -2 and <= 5)
111-
.ToArray();
112-
if (columns.Length == 1)
113-
setter(columns[0], columns[0], columns[0], columns[0]);
114-
else if (columns.Length == 4)
115-
setter(columns[0], columns[1], columns[2], columns[3]);
116-
else
117-
{
118-
//todo invalidate
119-
}
120-
}
121-
122-
123-
}
124-
public class GridItemCardBlock(DirectiveBlockParser parser, Dictionary<string, string> properties)
125-
: DirectiveBlock(parser, properties)
126-
{
127-
public override void FinalizeAndValidate(ParserContext context)
128-
{
129-
}
130-
}

src/Elastic.Markdown/Slices/Directives/Card.cshtml

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/Elastic.Markdown/Slices/Directives/Grid.cshtml

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/Elastic.Markdown/Slices/Directives/GridItemCard.cshtml

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/Elastic.Markdown/Slices/Directives/SideBar.cshtml

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/Elastic.Markdown/Slices/Directives/_ViewModels.cs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public class VersionViewModel
2929
public required string Title { get; init; }
3030
}
3131

32-
public class SideBarViewModel;
3332
public class TabSetViewModel;
3433

3534
public class TabItemViewModel
@@ -39,23 +38,6 @@ public class TabItemViewModel
3938
public required string Title { get; init; }
4039
}
4140

42-
public class CardViewModel
43-
{
44-
public required string? Title { get; init; }
45-
public required string? Link { get; init; }
46-
}
47-
48-
public class GridViewModel
49-
{
50-
public required GridResponsive BreakPoint { get; init; }
51-
}
52-
53-
public class GridItemCardViewModel
54-
{
55-
public required string? Title { get; init; }
56-
public required string? Link { get; init; }
57-
}
58-
5941
public class IncludeViewModel
6042
{
6143
public required string Html { get; init; }

0 commit comments

Comments
 (0)