File tree Expand file tree Collapse file tree 4 files changed +41
-8
lines changed
src/Elastic.Markdown/Myst/Directives
tests/Elastic.Markdown.Tests/Inline Expand file tree Collapse file tree 4 files changed +41
-8
lines changed Original file line number Diff line number Diff line change 11---
22title : Substitutions
33sub :
4- ' frontmatter_key ' : " Front Matter Value"
4+ frontmatter_key : " Front Matter Value"
5+ version : 7.17.0
56---
67
78Here are some variable substitutions:
89
910| Value | Source |
1011| ------------------- | ------------ |
11- | {{frontmatter_key}} | Front Matter |
12+ | {{frontmatter_key}} | Front Matter |
13+
14+ Substitutions should work in code blocks too.
15+
16+ ``` {code} sh
17+ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{version}}-linux-x86_64.tar.gz
18+ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512
19+ shasum -a 512 -c elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512 <1>
20+ tar -xzf elasticsearch-{{version}}-linux-x86_64.tar.gz
21+ cd elasticsearch-{{version}}/ <2>
22+ ```
Original file line number Diff line number Diff line change 55// This file is licensed under the BSD-Clause 2 license.
66// See the license.txt file in the project root for more information.
77
8+ using Elastic . Markdown . Myst . Substitution ;
89using Elastic . Markdown . Slices ;
910using Elastic . Markdown . Slices . Directives ;
1011using Markdig ;
@@ -255,6 +256,9 @@ void RenderLeaf(LeafBlock p)
255256 renderer . EnableHtmlForInline = false ;
256257 foreach ( var oo in p . Inline ?? [ ] )
257258 {
259+
260+ if ( oo is SubstitutionLeaf sl )
261+ renderer . Write ( sl . Replacement ) ;
258262 if ( oo is LiteralInline li )
259263 renderer . Write ( li ) ;
260264 if ( oo is LineBreakInline )
Original file line number Diff line number Diff line change @@ -22,12 +22,7 @@ public override async Task InitializeAsync()
2222 {
2323 await base . InitializeAsync ( ) ;
2424 Block = Document
25- . Where ( block => block is ParagraphBlock )
26- . Cast < ParagraphBlock > ( )
27- . FirstOrDefault ( ) ?
28- . Inline ?
29- . Where ( block => block is TDirective )
30- . Cast < TDirective > ( )
25+ . Descendants < TDirective > ( )
3126 . FirstOrDefault ( ) ;
3227 }
3328
Original file line number Diff line number Diff line change @@ -62,3 +62,26 @@ public void GeneratesAttributesInHtml() =>
6262 """{{valid-key}}"""
6363 ) ;
6464}
65+
66+ public class SubstitutionInCodeBlockTest ( ITestOutputHelper output ) : LeafTest < SubstitutionLeaf > ( output ,
67+ """
68+ ---
69+ sub:
70+ version: "7.17.0"
71+ ---
72+ ```{code} sh
73+ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{version}}-linux-x86_64.tar.gz
74+ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512
75+ shasum -a 512 -c elasticsearch-{{version}}-linux-x86_64.tar.gz.sha512 <1>
76+ tar -xzf elasticsearch-{{version}}-linux-x86_64.tar.gz
77+ cd elasticsearch-{{version}}/ <2>
78+ ```
79+ """
80+ )
81+ {
82+
83+ [ Fact ]
84+ public void GeneratesAttributesInHtml ( ) =>
85+ Html . Should ( ) . Contain ( "7.17.0" ) ;
86+ }
87+
You can’t perform that action at this time.
0 commit comments