europa icon indicating copy to clipboard operation
europa copied to clipboard

Option to allow inline HTML

Open neocotic opened this issue 13 years ago • 6 comments

When enabled (via the options) the parser should only clean specified HTML elements (i.e. remove all of their attributes) instead of replacing them with Markdown. When "cleaning" an element, all of its children will also be "cleaned" by the parser instead of converted into Markdown.

This functionality will be extremely useful when using tables.

The option should allow users to specify an array of specific tags;

md html, inline: ['p', 'table']

In this example it would "clean" all <p> and <table> tags, along with all their children.

neocotic avatar Dec 12 '12 12:12 neocotic

This won't be included in the next release as it'll require a lot of work to ensure "cleaned" elements (and especially their children) are formatted as you'd expect (e.g. indentation).

neocotic avatar May 02 '13 13:05 neocotic

I would appreciate having inline html that can't be converted to markdown left intact.

jaredly avatar Aug 30 '13 05:08 jaredly

+1 @jaredly about leaving raw

Currently, I don't want to change all tables, only some (due to size). I am wondering if we could have the inline option css selector based?

toddb avatar Dec 19 '13 19:12 toddb

@jaredly A lot of elements that can't be converted are just removed (e.g. <object>) or have their contents rendered (e.g. <div>). This is best in the majority of cases as lots of these elements could exist if this tool was used to parse a full page's HTML. This option will be used to provide exceptions instead of changing all funcitonality. Perhaps another - separate - option could be added for what you're describing, if I'm understanding you correctly.

@toddb Great idea! I'll definitely consider that when looking at implementing this.

neocotic avatar Dec 19 '13 19:12 neocotic

It does seem to me that the first (experimental) versions of this feature could be 'buyer beware' - if you include raw html you should have cleaned it first. In practice, this is what I am doing with tidy and some custom cleaning because my html is so raw. (I am doing one-off migration of content and suspect this isn't your key use case)

toddb avatar Dec 19 '13 19:12 toddb

Fwiw, I'm currently using this lib because it strips all HTML which can't be converted. I'm using it to convert Word docs into Markdown, so it's a long process with lots of crazy tags.

So if an option is added to keep inline HTML, I would really appreciate this being optional.

Also, thanks so much for this lib! :star2:

katowulf avatar Dec 19 '13 21:12 katowulf