Most of the time Markdown files are treated just like source code: they're in a VCS, they take part in pull requests and/or reviews, and they're well formatted. And just like in source code, I often see inserted line breaks at a specific length—like a code formatter would do.
Many editors do that dynamically according to the current window size (a.k.a. word wrap). Furthermore, Markdown is mainly used to generate HTML pages, PDF documents, or other formats. Manually inserted line breaks often lead to messed up text rendering in these situations.
Is wrapping Markdown at a specific line length good or bad? The topic seems to be controversial, even the current CommonMark specification (v0.29) somewhat sits on the fence:
A regular line break (not in a code span or HTML tag) that is not preceded by two or more spaces or a backslash is parsed as a softbreak. (A softbreak may be rendered in HTML either as a line ending or as a space. The result will be the same in browsers. In the examples here, a line ending will be used.)
[…]
A conforming parser may render a soft line break in HTML either as a line break or as a space.
A renderer may also provide an option to render soft line breaks as hard line breaks.
However, John Gruber said back in 2004:
The implication of the “one or more consecutive lines of text” rule is that Markdown supports “hard-wrapped” text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type’s “Convert Line Breaks” option) which translate every line break character in a paragraph into a
<br />
tag.When you do want to insert a
<br />
break tag using Markdown, you end a line with two or more spaces, then type return.Yes, this takes a tad more effort to create a
<br />
, but a simplistic “every line break is a<br />
” rule wouldn’t work for Markdown. Markdown’s email-style blockquoting and multi-paragraph list items work best — and look better — when you format them with hard breaks.
To create a line break or new line ( <br> ), end a line with two or more spaces, and then type return. This is the first line.
In a Markdown file or widget, enter two spaces before the line break to begin a new paragraph, or enter two line breaks consecutively to begin a new paragraph.
There are a few different methods to enforce a line break in the same paragraph in Markdown syntax: HTML's <br /> , backslash and double space.
Wrap-codes allows the agents to just select an action from the drop-down menu and move on to the next call. Wrap-up codes can also be used to tag a customer number as a disconnected one or tag a customer as one who does not wish to receive any call.
Most Markdown renderers ignore single linebreaks, so wrapping the text around some agreed-upon length won't affect the rendered outcome.
It would, however, potentially make the code much easier to maintain.
So it is not an anti-pattern and some projects even require it in their coding standards. Example from libstoragemgmt-doc:
" Set text width as 72.
autocmd Filetype markdown set tw=72
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With