Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to allow inline HTML #11

Open
neocotic opened this issue Dec 12, 2012 · 6 comments
Open

Option to allow inline HTML #11

neocotic opened this issue Dec 12, 2012 · 6 comments

Comments

@neocotic
Copy link
Owner

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.

@ghost ghost assigned neocotic Dec 12, 2012
@neocotic
Copy link
Owner Author

neocotic commented May 2, 2013

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).

@jaredly
Copy link

jaredly commented Aug 30, 2013

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

@toddb
Copy link

toddb commented Dec 19, 2013

+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?

@neocotic
Copy link
Owner Author

@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.

@toddb
Copy link

toddb commented Dec 19, 2013

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)

@katowulf
Copy link

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! 🌟

bergie added a commit to bergie/html.md that referenced this issue Aug 4, 2014
bergie added a commit to bergie/html.md that referenced this issue Aug 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants