Skip to content

Extending the Markdown parser for a new Vue component #1119

Closed Locked Answered by brc-dd
6r1d asked this question in Q&A
Discussion options

You must be logged in to vote

What kind of syntax do you want, can you show us an example. Is it something like this:

::: foo bar
baz
:::

or simply ::: foo without any props?

If it's first one, then you can have a look at this example: #313 (comment) or https://github.com/markdown-it/markdown-it-container#example or https://github.com/vuejs/vitepress/blob/main/src/node/markdown/plugins/containers.ts.

If it's second one, then you can simply do:

    md.use(container, 'foo', {
      render: (tokens: Token[], idx: number) =>
        tokens[idx].nesting === 1 ? `<div class="foo">\n` : `</div>\n`
    })

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@6r1d
Comment options

@brc-dd
Comment options

Answer selected by 6r1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants