-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
How to add custom html tags #514
Comments
Well, |
This is very inconvenient, I am creating a documentation for my project which involves displaying the element, however unfortunately is automatically added a paragraph around. My Angular directive: <pf-panel>
<pf-body>
<p>Exemplo de painel com corpo.</p>
</pf-body>
</pf-panel> The results: <p><pf-panel>
<pf-body>
<p>Exemplo de painel com corpo.</p>
</pf-body>
</pf-panel></p> Perhaps not the purpose of this project ... |
@chjj if you have a little time, please take a look on this issue 👍 |
Okay, partially it is working:
|
That is because there is a difference between an HTML block and inline HTML. Any inline element will get wrapped by a |
It's super late to join this issue, but I'd like to share an alternative approach that utilizes directive syntax which might be suitable for your needs: import { Marked } from 'marked'
import { createDirectives, presetDirectiveConfigs } from 'marked-directive'
const markdown = `::::example{#foo.bar}
:::file{name="index.html"}
\`\`\`html
<div class="example">
<p>example code here</p>
</div>
\`\`\`
:::
::::
`
const html = new Marked()
.use(
createDirectives([
...presetDirectiveConfigs,
{ level: 'container', marker: '::::' }
])
)
.parse(markdown)
console.log(html) Yields: <example id="foo" class="bar">
<file name="index.html">
<pre><code class="language-html"><div class="example">
<p>example code here</p>
</div>
</code></pre>
</file>
</example> |
I want to add some custom html tags like this:
but it seems
<example>
and<file>
tag are not recognised as a valid html tag. marked think they are paragraph elements and add a couple of<p>
around themthe compiled content is:
This behave make the
<example>
and<file>
tag fail to workThe text was updated successfully, but these errors were encountered: