driusan/lmt

Windows line endings not working

Opened this issue · 1 comments

After testing a file in github discussions #22, lmt seems to fail with Windows style \r\n line endings. I haven't had a chance to dig into why, but there's likely a regex somewhere that needs to be updated to support Windows.

Hi Dave,

As far as I can see, this is easy to fix (just 2 or 3 lines of code, essentially):

In Implementation.md, line 265:
Replace
if line.text == "\n" by if line.text == "\n" || line.text == "```\r\n" {

In IndentedBlocks.md, line 120:
Replace
if line.text == "\n" { by if line.text == "\n" || line.text == "```\r\n" {
and the same in line 103 (for the documentation).

Similar changes must be made in
LineNumbers.md, line 146:
Replace
if line.text == "\n" { by if line.text == "\n" || line.text == "```\r\n" {
and in line 236:
Replace
if v.text != "\n" {
by
if v.text != "\n" && v.text != "\r\n" {

Not elegant, but simple, and lmt can now work with Windows and Unix line endings on both platforms (regardless where the markdown files to tangle have been produced).

Thanks for your nice work - I really appreciate lmt!

Regards, Harald