gomarkdown / markdown

markdown parser and HTML renderer for Go
Other
1.38k stars 172 forks source link

How to render custom tags? #222

Closed kaiaverkvist closed 2 years ago

kaiaverkvist commented 2 years ago

Let's say I want to add a tag to embed a specific piece of HTML in place of it. How do I do that?

kjk commented 2 years ago

Not sure I understand, would be clearer if you provided an example of markdown and your desired html output.

What I did to insert arbitrary html is via post-processing of html output. Markdown would be:

this is **markdown content**.

!my-arbitrary-stuff

rest of markdown content.

Convert this to HTML and then replace !my-arbitrary-stuff with whatever HTML you want via strings.Replace().

It's a hack but this is the easiest way.