#Line breaks \

9 messages · Page 1 of 1 (latest)

warm violet
#

Hey! Could someone enlighten me, why we need special syntax for line breaks \, instead of just using the line break character itself \n?

To me, it seems super counter-intuitive, as it needlessly breaks the visual similarity of markup and final document.

last ice
#

it is a good practise, for example, to put every sentence in a separate line in your code such that line based diffs (as you'd have in git) work on semantic units. personally, i also limit my code lines to 80 characters as well to ensure readability regardless of the editor. in both cases, i wouldn't want the syntactic linebreaks in my code have an effect on the rendered document. that's why LaTeX, Typst, and (certain implementations of) markdown ignore single \n characters in your code

warm violet
#

Can you give me an example where you use \n, don't want a linebreak and automatic line wrapping by editor doesn't suffice?

last ice
#
This is a short sentence.
This is another.
inland whale
#

I don't split my lines per-sentence, I instead just wrap them at 80/100/120 depending on the language I'm using. Not only do I simply prefer it, but like a5sk6n says, it gives line-based source control more stuff to grab onto.

warm violet
#

Ok, in such case, why not make \n\n equal to \n and \n\n\n equal to \n\n?

inland whale
#

...or, why not make \n equal to and make \n\n equal to \n? 😛

#

Another reason is that hard-wrapping lines at some specific column with line-feeds is an established convention, especially in the early computing space. Everything was on a terminal and nothing was consistent, Things were written that way to make sure stuff was legible either in plain-text, terminal form, or in email or printed or wherever else.

Just look at RFCs: Both of TCP and IP's original documents are hard-wrapped at 72 characters. New ones are, too.