lmt icon indicating copy to clipboard operation
lmt copied to clipboard

Windows line endings not working

Open driusan opened this issue 4 years ago • 1 comments

After testing a file in github discussions https://github.com/driusan/lmt/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.

driusan avatar Jul 22 '21 16:07 driusan

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

ehrentraut avatar Aug 24 '21 16:08 ehrentraut