icyleaf / markd

Yet another markdown parser, Compliant to CommonMark specification, written in Crystal.
MIT License
109 stars 30 forks source link

gfm: add tagfilter option #64

Closed nobodywasishere closed 3 months ago

nobodywasishere commented 3 months ago

When enabled (alongside the gfm option), it will escape certain HTML tags

require "./src/markd"

markdown = <<-MD
# Hello Markd

> Yet another markdown parser built for speed, written in Crystal, Compliant to CommonMark specification.

<title>this isn't allowed</title>

<style>
  title {
    font-size: 100px;
  }
</style>
MD

options = Markd::Options.new(gfm: true, tagfilter: true)
puts Markd.to_html(markdown, options)

Output:

<h1>Hello Markd</h1>
<blockquote>
<p>Yet another markdown parser built for speed, written in Crystal, Compliant to CommonMark specification.</p>
</blockquote>
&lt;title>this isn't allowed&lt;/title>
&lt;style>
  title {
    font-size: 100px;
  }
&lt;/style>