Reading — step 1 of 5
Read
~1 min readBlock Elements
Paragraphs & Line Breaks
Plain text becomes <p> blocks. Paragraphs are separated by blank lines:
First paragraph
spans multiple lines.
Second paragraph
also spans.
Compiles to:
<p>First paragraph spans multiple lines.</p>
<p>Second paragraph also spans.</p>
Note: a single \n within a paragraph becomes a SPACE (lines join). To force a <br> break:
- Two trailing spaces, then
\n - Or
\at end of line (CommonMark "hard line break")
Line 1
Line 2
Output:
<p>Line 1<br />Line 2</p>
Implementation: process line-by-line, maintaining a state machine. Blank line = end-of-paragraph trigger.
python
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…