I was working on a component that used snarkdown/marked on my mac, and it was working fine. Then I switched to my windows desktop to make some quick changes, and parsing code blocks was broken. I was pulling them via esbuild loaders, and feeding an inline string worked fine. I finally figured out that \r\n was being used instead of \n for the line endings, and I guess that breaks the regex.
So my possible fix is essentially just to prefix each \n with an optional \r. The bundle grows by about 6 bytes on average (not past 1k), comparison is below.
Workaround is just to replace carriage returns in the input before it's fed in, which is fine, but it'd be nice to offload that into the library if possible.
I was working on a component that used snarkdown/marked on my mac, and it was working fine. Then I switched to my windows desktop to make some quick changes, and parsing code blocks was broken. I was pulling them via esbuild loaders, and feeding an inline string worked fine. I finally figured out that
\r\n
was being used instead of\n
for the line endings, and I guess that breaks the regex.So my possible fix is essentially just to prefix each
\n
with an optional\r
. The bundle grows by about 6 bytes on average (not past 1k), comparison is below.Workaround is just to replace carriage returns in the input before it's fed in, which is fine, but it'd be nice to offload that into the library if possible.
Thanks!
Before
After