Search code examples
markdownnewlinereadme

Markdown how to spread out header source over several lines, while still rendering as one continuous header


I have a header 2 (## h2) that has a lot of text (over 80 characters). I try to keep the lines within markdown files within 80 characters, and so by breaking up long lines.

Goal: wrap a long header line's text in the source, without affecting the rendering

With normal sentences, this is easy... the markdown properly renders as one continuous sentence:

This is a very very very very very very very very very very very very very very 
very very very very very very very very very very long line.

normal text with a line wrap

However, I can't figure out how to do this with headers. If I make a second header line in the source, the markdown is rendered as two different lines of header 2.

## This is a very very very very very very very very very very very very very 
## very very very very very very very very very very very long header.

h2 with a line wrap

How can I make markdown line wrapping work like normal text, except for header 2?


Solution

  • This question is a duplicate of How to break a long headed line in markdown pandoc? from 5 years ago

    There is nothing in Markdown syntax about being able to break up lines -- see https://daringfireball.net/projects/markdown/syntax

    There was some discussion about adding this capability to pandoc's markdown processor in https://github.com/jgm/pandoc/issues/82 but ultimately the issue was closed without changing anything.

    So in short the answer is no, you can't break up the header source over several lines in Markdown while still rendering as one continuous header.