-
Notifications
You must be signed in to change notification settings - Fork 433
breaks
Crozzers edited this page Dec 9, 2023
·
3 revisions
The breaks extra, added in 2.4.11, allows you to control when hard breaks (<br />
) are inserted into the markdown. This extra includes the functionality of the old break-on-newline
extra (added in 2.2.0), which has been kept as an alias of breaks
.
Two options are provided, both disabled by default:
-
on_newline
(replacesbreak-on-newline
extra): replace single newline characters with hard breaks -
on_backslash
: lines ending in a backslash will have a hard break inserted
When `on_newline` is enabled, there will be a `<br />` tag at the end of this line
But not this one, since it's at the end of the file
<p>When <code>on_newline</code> is enabled, there will be a <code><br /></code> tag at the end of this line<br />
But not this one, since it's at the end of the file</p>
This line will have a line break \
Due to the backslash
<p>This line will have a line break<br />
Due to the backslash</p>
markdown2.markdown(your_text, extras={'breaks': {'on_newline': True, 'on_backslash': True}})