ohare93 / brain-brew

Automated Anki flashcard creation and extraction to/from Csv
The Unlicense
89 stars 5 forks source link

fix: Allow different types of EOL in note model template regex #53

Closed dominik-oktav closed 3 weeks ago

dominik-oktav commented 5 months ago

As reported in #51, the current regex doesn't work on Windows. I adapted the regex to allow \r\n, \n and \r.

helitopia commented 3 weeks ago

Hi everyone,

Any updates on the PR?

Also, is there a reason the regex (?:\r?\n){1,}[-]{1,}(?:\r?\n){1,} is not used? (It is either \n for Linux or \r\n for Windows)

And in general it would be great to merge any solution that works as the issue may potentially block eager Windows-using contributors to Ultimate Geography repo (and any other using brain_brew). Not everyone is able to debug Python code and figure out the root cause of the issue (let alone to fix it locally).

aplaice commented 3 weeks ago

Also, is there a reason the regex (?:\r?\n){1,}[-]{1,}(?:\r?\n){1,} is not used? (It is either \n for Linux or \r\n for Windows)

I suspect that the slightly more general regex was chosen because technically, there are/were systems where just \r is/was used. (Classic MacOS if I remember correctly.) This is probably more relevant in situations where one has to handle old text files, though; here, I expect we will never encounter such files since Anki itself is younger than the unix-based MacOS. OTOH it doesn't really hurt.

ohare93 commented 3 weeks ago

Lovely, thanks all. I’ll give it a quick test on Windows tomorrow night, then make a release shortly thereafter.