mxfe
mxfe

Reputation: 363

Pandoc: Convert Markdown to HTML *without* any HTML attributes

Is there a way to tell Pandoc to convert Markdown to HTML in such a way that generates only plain HTML tags without any attributes/classes?

Example:

Current Pandoc output

<pre class="sourceCode bash">
  <code class="sourceCode bash">
      TEXT
  </code>
</pre>

Desired Pandoc output

<pre>
  <code>
      TEXT
  </code>
</pre>

I browsed the official documentation but didn't find any options to do that.

Thanks!

Upvotes: 8

Views: 2901

Answers (1)

tarleb
tarleb

Reputation: 22659

There is no built-in option, but you can use a simple filter to remove all attributes and classes. Save the following to a file remove-attr.lua and call pandoc with --lua-filter=remove-attr.lua.

function remove_attr (x)
  if x.attr then
    x.attr = pandoc.Attr()
    return x
  end
end

return {{Inline = remove_attr, Block = remove_attr}}

Upvotes: 10

Related Questions