JohannesKaufmann/html-to-markdown

๐Ÿ› Bug with square brackets

alicewriteswrongs opened this issue ยท 4 comments

Describe the bug

Found an issue with square brackets in the input which is confusing me. They end up being converted to \$& in the output. This seems to happen whether they are written in the html as [], [, or [.

HTML Input

<p>first [literal] brackets</p>
<p>then &#91;one&#93; way to escape</p>
<p>then &lbrack;another&rbrack; one</p>

Generated Markdown

first \$&literal\$& brackets

then \$&one\$& way to escape

then \$&another\$& one

Expected Markdown

first \[literal\] brackets

then &#91;one&#93; way to escape

then &lbrack;another&rbrack; one

Additional context

I had this issue come up with some options configured, but then went ahead and removed all configuration to test and I'm still seeing it. Is it something on my end I'm doing incorrectly perhaps? I'm not very experienced with golang so it's possible I'm making a silly error.

@aliceriot Hmm, can you post your code and the website where you have it from?

I added a test case with this html (see commit input.html -> output.default.golden -> goldmark.golden) and it works without problems.

hey! so I put up a PR on my project with a minimal, failing example here: alicewriteswrongs/wget2hugo#4

As I said above I'm relatively new to go (well, I sort of learned it a few years ago but then didn't ever build a big project in it) so I could be doing something very silly and not seeing it ๐Ÿ˜„

The problem, as it turns out, is that I was using an old version of your code, and updating to the latest version seems to have fixed it! Sorry for the noise, and thanks for you help ๐Ÿ˜ƒ

@aliceriot no problem at all. Nice that you found the problem ๐Ÿ‘

Good luck with learning Golang. If you have any question about the library, just let me know...