suntong / html2md

HTML to Markdown converter
MIT License
226 stars 19 forks source link

Option to disable "\" shielding #2

Closed itdoginfo closed 1 year ago

itdoginfo commented 3 years ago

Two example:

echo "<p>tar -xvjf OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2</p>" | html2md -i
tar -xvjf OpenWrt-ImageBuilder-ar71xx\_generic-for-linux-x86\_64.tar.bz2

and

echo "<strong>option src_ip</strong>" | html2md -i
**option src\_ip**

Shielding \ spoils my formatting. Is it possible to disable this?

suntong commented 1 year ago

Sorry I had the wrong notice setting and was only able to notice your issue just now. Will look into it...

suntong commented 1 year ago

Hmm.. that comes from github.com/JohannesKaufmann/html-to-markdown itself -- testing with cascadia:

$ echo "<strong>option src_ip</strong>" | cascadia -o -i -c strong -t
option src_ip

and I now think it make sense, as _ has a special meaning in markdown.

Maybe you've chose the wrong tool, but want to use cascadia instead?

suntong commented 1 year ago

Anyhow, it'll be possible after building with the latest feature of https://github.com/JohannesKaufmann/html-to-markdown#escaping

itdoginfo commented 1 year ago

Thanks for the suggested solution. But what I needed was a conversion to markdown with attributes preserved. It is no longer relevant to me. But I hope you do a build with this feature. Thanks for your time and product!

suntong commented 1 year ago

@all-contributors please add @itdoginfo for bug, userTesting

allcontributors[bot] commented 1 year ago

@suntong

I've put up a pull request to add @itdoginfo! :tada:

itdoginfo commented 1 year ago

Now it works:

echo "<p>tar -xvjf OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2</p>" | html2md -i --opt-escape-mode disable
tar -xvjf OpenWrt-ImageBuilder-ar71xx_generic-for-linux-x86_64.tar.bz2
echo "<strong>option src_ip</strong>" | html2md -i --opt-escape-mode disable
**option src_ip**

Thanks!