subconsciousnetwork / subtext

Markup for note taking
Apache License 2.0
273 stars 20 forks source link

Define line break #4

Closed nichtich closed 3 years ago

nichtich commented 3 years ago

Which character(s) are considered a line break? LF? Also CRLF? All linebreaks defined by Unicode? I'd not include additional Unciode line breaks such as U+2029 so you can still use them for linebreaks within a block (if you your editor supports entering it instead of a normal line break)

gordonbrander commented 3 years ago

This is a great call-out, thank you!

My instinct is to define line breaks in terms of Unix and Windows ASCII newline escape sequences, so: \n and \r\n at the end of a line would be treated equivalently as a line break.

Combing through https://en.wikipedia.org/wiki/Newline, I notice JSON and JavaScript treat newlines differently. JSON allows LS and PS in strings, while ECMAScript prior to ES2019 treats them as newlines.

Anyone happen to have links on newline footguns? I'd love to do the most universal thing here, and I want to avoid spec'ing in an edge case that will bite later.

gordonbrander commented 3 years ago

Idea from Ade: “Standardise on Unix newlines and follow the Go approach of normalising every file you touch.” https://twitter.com/ade_oshineye/status/1396726639464169474?s=21

Issue discussion from Go decision https://github.com/golang/go/issues/16355