![]() This package is available under the MIT License. If you just need a standard and pure "HTML to Markdown" convertor, I recommend the following libraries: The interface was inspired by the bleach user-input sanitization library, which relies on html5lib whitespace is shown via HTML rendering rules.blank lines are dropped to the lowest allowable nesting of blockquotes or lists.There is a max of 2 newlines (1 blank line) between elements.They are not compatible with the html5lib parser, and trying to support them will require a lot of work. These other projects are all great, but require re-processing if you are already doing things with html5lib.Īngled links are not currently supported, for example: Other packages use BeautifulSoup, lxml or HTMLParser. This package is implemented as a htmllib5 "tree adapter", which means it can be potentially be layered into many htm5lib processing routines. This package aims to keep Python2 support around a bit longer than the official cutoff date, because legacy systems exist.Ĭore Implementation Detail. Some excellent packages in this space stopped supporting Python2 already. This library should not add artifacts.Īt a minimum, our goal is this as_markdown = to_markdown(html) = to_markdown(to_html(as_markdown))Īs_html = to_html(as_markdown) = to_html(to_markdown(as_html))Ĭustomized feature: A departure from the core Markdown specification was needed for a few elements:Ĭustomized feature: Python2 and Python3 compatibility. This can't be guaranteed in all situations because of how Markdown and HTML work, but it is a goal. In other words, we're aiming for this:Īs_markdown = to_markdown(html) = to_markdown(as_markdown) = to_markdown(to_markdown(html)) = to_markdown(to_markdown(as_markdown)) This is more of a goal than a guarantee, but text that is processed through this library should not change if re-processed through this library whenever possible. This library attempts to optimize-away extra newlines and spaces, creating a concise and readable Markdown version.Ĭustomized Feature: ignore unwanted html tags and attributes.Ĭustomized Feature: Idempotent when possible. This library doesn't just create Markdown, but optimized/pretty Markdown. ![]() Sometimes we WANT to use and tags, and not turn them into Markdown syntax.Ĭustomized Feature: Clean up common html issues and make pretty Markdown. Several existing libraries do not have tests or adequate test coverage.Ĭustomized Feature: Use HTML for certain elements instead of Markdown syntax. This package ships with many tests to ensure things keep working as desired. There are no GPL restrictions, which affect about a third of the other libraries that perform this task. This package is available via the permissive MIT license. Why create another package to do this task? There are many packages that convert HTML to Markdown. More functionality will be added as needed. This package is currently targeting a SUBSET of full HTML->Markdown conversion to address internal needs. ![]() This package offers a way to convert HTML to the Markdown format. ![]()
0 Comments
Leave a Reply. |