mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
756 stars 138 forks source link

Literal ampersand always expanding to & even when using --fverbatim-entities #118

Closed evil-rob closed 4 years ago

evil-rob commented 4 years ago

Standard behavior without any flags seems to be to expand literal ampersands in the markdown input to produce & in the html output and to interpret other character entities in the input to produce unicode characters in the output. For example: # in the input produces # in the output.

$ echo -n 'entity: &' | md2html
<p>entity: &amp;</p>
$ echo -n 'entity: &amp;' | md2html
<p>entity: &amp;</p>
$ echo -n 'entity: &num;' | md2html
<p>entity: #</p>

This is fine, but when --fverbatim-entities is used, the literal ampersand in the character entity in the mardown input is still expanded to &amp;

$ echo -n 'entity: &' | md2html --fverbatim-entities
<p>entity: &amp;</p>
$ echo -n 'entity: &amp;' | md2html --fverbatim-entities
<p>entity: &amp;amp;</p>
$ echo -n 'entity: &num;' | md2html --fverbatim-entities
<p>entity: &amp;num;</p>

When --fverbatim-entities is given, I would expect that entities are not interpreted in any way, and instead passed through the markdown interpreter to produce the same entity in the html output.

I am using the current version installed from Manjaro's repositories.

$ md2html --version
0.4.4
$ cat /etc/*release
Manjaro Linux
DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=20.0.3
DISTRIB_CODENAME=Lysia
DISTRIB_DESCRIPTION="Manjaro Linux"
Manjaro Linux
NAME="Manjaro Linux"
ID=manjaro
ID_LIKE=arch
BUILD_ID=rolling
PRETTY_NAME="Manjaro Linux"
ANSI_COLOR="32;2;24;144;200"
HOME_URL="https://manjaro.org/"
DOCUMENTATION_URL="https://wiki.manjaro.org/"
SUPPORT_URL="https://manjaro.org/"
BUG_REPORT_URL="https://bugs.manjaro.org/"
LOGO=manjarolinux
mity commented 4 years ago

Ack. Thanks for reporting it.

evil-rob commented 4 years ago

Thanks for fixing. Works great!