HTML to MD simple converter tool
- One javascript file
- Capable to run from your local disk
- No modules or any backend/framework needed
- around 7 kB (not minified)
- Supports base of standard output from Marked and Prism
- Part of bigger project that has been refactored to be independent
-
Demo implementation is a single HTML file to show you needed configuration to make it work.
- Scroll down and click Convert to TeX button
- Result will be shown in textarea under the button
- Copy button doesn't have any function and it is kept exactly as it is being produced by Prism library (manually copied here to demonstrate how does this case works)
-
HelpViewer integration source code: export handler and pre export preparation for image links collection. This code is executed when you will click on top right dropdown button (📥) and select MD format.
Add reference to head section:
<script src="https://raw.githubusercontent.com/HelpViewer/HTMLToMD/refs/heads/main/HTMLToMD.js" type="text/javascript"></script>or copy this file to your local environment.
Call HTMLToMD function with
parameters:
- parent - HTMLElement which contains all your HTML data which should be converted to TeX
- ctx - internal state context for single run (provide: { listStack: [], i_img: 0, i_svg: 0, embeds: new Map() } as default)
- listStack - ul/ol nesting sequence
- i_img - img tags found counter
- i_svg - svg tags found counter
- embeds - previously collected embedded objects (img, svg)
to get result : markdown source code.
- Tool focuses on using only the basic scenarios of format (possibly nesting objects and combinations in table can be incorrect)
- Text formatting functions are used only to a basic extent (despite your HTML can be more rich in format)
- Nested code listings are exported wrong (4 and 3 backticks blocks are exported as 3 and 3)
- No managed packages or artifacts are planned to be released from this repository
- Work directly with the content of the main branch of the GitHub repository
- Repository is used with Git submodules in HelpViewer project