Skip to content

Commit 446b4dc

Browse files
committed
fix(render) templatemark plugin render properly handles {{this}}
Signed-off-by: Jerome Simeon <[email protected]>
1 parent 5a3578b commit 446b4dc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/markdown-it-template/lib/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const variable_inline = function (tokens, idx /*, options, env */) {
4747
return `<span class="variable" ${attrs}>${name}</span>`;
4848
};
4949

50+
const this_inline = function (tokens, idx /*, options, env */) {
51+
return `<span class="variable" name="this">this</span>`;
52+
};
53+
5054
const else_inline = function (tokens, idx /*, options, env */) {
5155
return `</span><span class="else_inline">`;
5256
};
@@ -68,6 +72,7 @@ function template_plugin(md) {
6872
md.renderer.rules['inline_block_join_close'] = template_inline_render('join');
6973
md.renderer.rules['inline_block_else'] = else_inline;
7074
md.renderer.rules['variable'] = variable_inline;
75+
md.renderer.rules['this'] = this_inline;
7176
md.renderer.rules['formula'] = formula_inline;
7277

7378
md.block.ruler.before('fence', 'template_block', template_block, {

packages/markdown-it-template/test/data/all.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ <h1>Title</h1>
1616
<li>three</li>
1717
</ul>
1818
</div>
19-
<p>There is also a new <span name="name" class="optional_inline"> inline which can contain <this></span>.</p>
20-
<p>There is also a new <span name="name" class="optional_inline"> inline which can contain <this></span><span class="else_inline">something else</span>.</p>
19+
<p>There is also a new <span name="name" class="optional_inline"> inline which can contain <span class="variable" name="this">this</span></span>.</p>
20+
<p>There is also a new <span name="name" class="optional_inline"> inline which can contain <span class="variable" name="this">this</span></span><span class="else_inline">something else</span>.</p>
2121
<p>This is a <a href="mylink">link with a <span class="variable" name="variable">variable</span> in it</a>.</p>
22-
<p>This is a <a href="mylink">link with a <this> in it</a>.</p>
22+
<p>This is a <a href="mylink">link with a <span class="variable" name="this">this</span> in it</a>.</p>
2323
<p>This is a <a href="mylink">link with an <span name="name" class="if_inline"> in it</span></a>.</p>
2424
<p>This is a <a href="mylink">link with an <span name="name" class="optional_inline"> in it</span></a>.</p>
2525
<p>This is a <a href="mylink">link with a <span name="name" class="join_inline"> in it</span></a>.</p>

0 commit comments

Comments
 (0)