Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline complex container? #25

Closed
chris-dura opened this issue Jul 11, 2018 · 2 comments
Closed

Multiline complex container? #25

chris-dura opened this issue Jul 11, 2018 · 2 comments

Comments

@chris-dura
Copy link

chris-dura commented Jul 11, 2018

Hello, I've looked through the documentation, and I'm having a hard time figuring out how to do what I need. I think part of the problem is that the example only works when the markdown is all on a singleline, but the other example is on multilines:

::: warning
*here be dragons*
:::

Basically, with the following:

::: warning
## Beware!
*here be dragons*
_seriously, there are._
:::

I'd like to render out the following HTML:

<div class="warning">
  <div class="left-col"><h2>Beware!</h2></div>
  <div class="middle"><em>here be dragons</em></div>
  <div class="right"><em>seriously, there are.</em></div>
</div>
@chris-dura
Copy link
Author

chris-dura commented Jul 11, 2018

It seems that when passing a multiline the tokens[idx].info only has the first line, and not the content of the container...

::: spoiler click me\n*content*\n:::

::: warning
*here be dragons*
:::
var md = require('markdown-it')();

md.use(require('markdown-it-container'), 'spoiler', {
  ...
  render: function (tokens, idx) {
    console.log(tokens[idx].info); // output: spoiler click me\n*content*\n:::
    ...
  }
})
.use(require('markdown-it-container'), 'warning', {
  ...
  render: function (tokens, idx) {
    console.log(tokens[idx].info); // output: warning
    ...
  }
});

@puzrin
Copy link
Member

puzrin commented Jul 12, 2018

If you need nesting:

::: warning
:::: left-col
::::
:::: middle
::::
:::: right
::::
:::

Principle is the same as with fenced blocks - vary delimiter length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants