From 446b4dc41589523d0c26b15f17c0e7d731ab4efb Mon Sep 17 00:00:00 2001 From: Jerome Simeon Date: Fri, 7 Aug 2020 10:23:42 -0400 Subject: [PATCH] fix(render) templatemark plugin render properly handles {{this}} Signed-off-by: Jerome Simeon --- packages/markdown-it-template/lib/index.js | 5 +++++ packages/markdown-it-template/test/data/all.html | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/markdown-it-template/lib/index.js b/packages/markdown-it-template/lib/index.js index a52e198c..6802864e 100644 --- a/packages/markdown-it-template/lib/index.js +++ b/packages/markdown-it-template/lib/index.js @@ -47,6 +47,10 @@ const variable_inline = function (tokens, idx /*, options, env */) { return `${name}`; }; +const this_inline = function (tokens, idx /*, options, env */) { + return `this`; +}; + const else_inline = function (tokens, idx /*, options, env */) { return ``; }; @@ -68,6 +72,7 @@ function template_plugin(md) { md.renderer.rules['inline_block_join_close'] = template_inline_render('join'); md.renderer.rules['inline_block_else'] = else_inline; md.renderer.rules['variable'] = variable_inline; + md.renderer.rules['this'] = this_inline; md.renderer.rules['formula'] = formula_inline; md.block.ruler.before('fence', 'template_block', template_block, { diff --git a/packages/markdown-it-template/test/data/all.html b/packages/markdown-it-template/test/data/all.html index 4df11446..0e7e466a 100644 --- a/packages/markdown-it-template/test/data/all.html +++ b/packages/markdown-it-template/test/data/all.html @@ -16,10 +16,10 @@

Title

  • three
  • -

    There is also a new inline which can contain .

    -

    There is also a new inline which can contain something else.

    +

    There is also a new inline which can contain this.

    +

    There is also a new inline which can contain thissomething else.

    This is a link with a variable in it.

    -

    This is a link with a in it.

    +

    This is a link with a this in it.

    This is a link with an in it.

    This is a link with an in it.

    This is a link with a in it.