elliotblackburn / mdpdf

Markdown to PDF command line app with support for stylesheets
https://npmjs.com/package/mdpdf
Apache License 2.0
718 stars 48 forks source link

HTML tags in the markdown source are closed in the generated HTML #57

Open WaterSibilantFalling opened 5 years ago

WaterSibilantFalling commented 5 years ago

If someone has an HTML tag in their markdown, like

   <span class=ContactListTable>
        something
        something else
    </span>

in the generated HTML the tag is weirdly and obviously incorrectly automatically closed !

   <p><span class="ContactListTable"></span></p>
        something   // class attributes not applied;;
        something   // class attributes not applied;;

and the correct is removed

In mdpdf, the showdown library is used to create the intermediate HTML. In the showdown library documentation https://github.com/showdownjs/showdown/wiki/Showdown's-Markdown-syntax#handling-html-in-markdown-documents it says

Showdown, in most cases, leaves HTML tags alone, leaving them untouched in the output document.

However, in the mdpdf output, tags have been moved and closed.

Note: tags are also closed if markdown=1 is added to the HTML tag in the markdown.

Why? Why oh why?

elliotblackburn commented 5 years ago

We do absolutely nothing to the HTML at the moment other than injecting the header and footers, even this is abstracted at the moment. While the docs say that, it's worth us checking what it actually does. Do you have a markdown example with the html inside, is that top one an example that causes the issue?

Showdown have a tool on their web page for testing the output so I can use that to check how this works. This really shouldn't be an issue in the mdpdf logic.