Skip to content

Commit 00957d5

Browse files
committed
Add an action that validates if assembler.yml content-source mapping is fully published to the link registry
1 parent 0aca585 commit 00957d5

File tree

7 files changed

+22
-1981
lines changed

7 files changed

+22
-1981
lines changed

src/Elastic.Markdown/Assets/mermaid.ts renamed to src/Elastic.Markdown/Assets/mermaid.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import 'htmx-ext-head-support'
2-
import 'htmx-ext-preload'
3-
import 'htmx.org'
4-
import mermaid from '@mermaid-js/tiny/dist/mermaid.tiny'
5-
61
var mermaidInitialize = function () {
72
mermaid.initialize({
83
startOnLoad: false, theme: 'base',

src/Elastic.Markdown/IO/MarkdownFile.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Elastic.Markdown.IO.Navigation;
1414
using Elastic.Markdown.Links.CrossLinks;
1515
using Elastic.Markdown.Myst;
16+
using Elastic.Markdown.Myst.CodeBlocks;
1617
using Elastic.Markdown.Myst.Directives;
1718
using Elastic.Markdown.Myst.FrontMatter;
1819
using Elastic.Markdown.Myst.InlineParsers;
@@ -152,6 +153,8 @@ public string Url
152153
/// because we need to minimally parse to see the anchors anchor validation is deferred.
153154
public IReadOnlyDictionary<string, string?>? AnchorRemapping { get; set; }
154155

156+
public bool HasMermaidBlock { get; private set; }
157+
155158
private void ValidateAnchorRemapping()
156159
{
157160
if (AnchorRemapping is null)
@@ -187,6 +190,9 @@ public async Task<MarkdownDocument> ParseFullAsync(Cancel ctx)
187190
_ = await MinimalParseAsync(ctx);
188191

189192
var document = await GetParseDocumentAsync(ctx);
193+
194+
HasMermaidBlock = document.Descendants<EnhancedCodeBlock>().Any(b => b.Language == "mermaid");
195+
190196
return document;
191197
}
192198

@@ -333,7 +339,7 @@ private YamlFrontMatter ProcessYamlFrontMatter(MarkdownDocument document)
333339
Title = deprecatedTitle;
334340
}
335341

336-
// set title on yaml front matter manually.
342+
// set title on YAML front matter manually.
337343
// frontmatter gets passed around as page information throughout
338344
fm.Title = Title;
339345
return fm;
@@ -359,7 +365,7 @@ private YamlFrontMatter ReadYamlFrontMatter(string raw)
359365

360366
public static string CreateHtml(MarkdownDocument document)
361367
{
362-
//we manually render title and optionally append an applies block embedded in yaml front matter.
368+
//we manually render the title and optionally append an `applies block` embedded in YAML front matter.
363369
var h1 = document.Descendants<HeadingBlock>().FirstOrDefault(h => h.Level == 1);
364370
if (h1 is not null)
365371
_ = document.Remove(h1);

src/Elastic.Markdown/Slices/Layout/_Footer.cshtml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@
3636
</footer>
3737

3838
<script src="@Model.Static("main.js")"></script>
39+
@if (Model.CurrentDocument.HasMermaidBlock)
40+
{
41+
<script src="@Model.Static("mermaid.js")"></script>
42+
}

src/Elastic.Markdown/_static/mermaid.js

Lines changed: 1 addition & 1971 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Elastic.Markdown/_static/mermaid.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Elastic.Markdown/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import globals from 'globals'
44
import tseslint from 'typescript-eslint'
55

66
export default defineConfig([
7-
globalIgnores(['_static/main.js']),
7+
globalIgnores(['_static/main.js', '_static/mermaid.js']),
88
{ files: ['**/*.{js,mjs,cjs,ts}'] },
99
{
1010
files: ['**/*.{js,mjs,cjs,ts}'],

src/Elastic.Markdown/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@
1818
},
1919
"js2": {
2020
"distDir": "_static",
21-
"source": "Assets/mermaid.ts"
21+
"source": "Assets/mermaid.js"
22+
},
23+
"js3": {
24+
"distDir": "_static",
25+
"source": "node_modules/@mermaid-js/tiny/dist/mermaid.tiny.js",
26+
"outputFormat": "global",
27+
"optimize": false
2228
},
2329
"css": {
2430
"distDir": "_static",

0 commit comments

Comments
 (0)