Skip to content

Can't get correct interpolation for codeblock in markdown #512

@avishnyakov

Description

@avishnyakov

Bug report

Can't get correct interpolation for codeblock in markdown. Followed approach with custom Vue component to inject markdown content via slot described below:

That works well for inline markdown within a Vue component. However, does not seem to work if interpolation is used within markdown codeblock. That prevents rendering source code which is stored elsewhere outside of markdown pages - metadata, front matter or external files.

MarkdownInVue.vue

<template>
  <div>
    <slot></slot>
  </div>
</template>

Then using directive over JSON data:

{
    "samples": [
        {
            "title":"sample1",
            "description": "descriptoin 1",
            "code": "\nvar i = 1;\n"
        },
         {
            "title":"sample2",
            "description": "descriptoin 2",
            "code": "\nvar i = 2;\n"
        }
    ] 
}

Later my markdown file:

// just preloaded mentioned JSON into themeConfig.samples variable
<div v-for="(item, index) in this.$site.themeConfig.samples">
{{ item.title }} with source code:

<MarkdownInVue>

  ## {{ item.title  }}
  {{ item.description }}

  \~~~~ 
  {{ item.code }} 
  \~~~~ 

  \```
  {{ item.code }} 
  \```

</MarkdownInVue>

</div>

Outcome:

image

Version

0.10.0

Steps to reproduce

As per setup early

What is expected?

Either of these:

  1. VuePress allows interpolation within codeblock in markdown so that the source code can be rendered dynamically.
  2. VuePress provides means to render source code from variable (which is stored elsewhere outside of markdown pages - metadata, front matter or external file)

What is actually happening?

VuePress skips interpolation for markdown codeblock.

Other relevant information

  • Your OS: Windows
  • Node.js version: v9.5.0
  • Is this a global or local install? - Global
  • Which package manager did you use for the install? - npm

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions