Add breaks extra with ability to hard break on backslashes (issue #525)#529
Add breaks extra with ability to hard break on backslashes (issue #525)#529nicholasserra merged 3 commits intotrentm:masterfrom
breaks extra with ability to hard break on backslashes (issue #525)#529Conversation
|
Looks great, thank you! |
|
Thank you. I assume it should be mentioned here at some point, right? Especially now that a version with this feature was released. |
|
Good shout. I've added a quick page for it here: https://github.com/trentm/python-markdown2/wiki/breaks |
|
Looks good. I think it makes sense to link it from the Extras page I mentioned. |
|
Updated the list of implemented extras as well |
|
Looks like the text in the wiki contradicts the actual behavior: <p>This line will have a line break<br />
But not this one<br />
Because the backslash has to have a space before it</p>A space before a backslash isn't required. Also, I created a PR with some improvements: #544 |
Thanks for spotting this. Updated the wiki to reflect actual behaviour.
Very cool! Thank you |
This PR closes #525 by adding the ability to insert hard breaks when lines end in a backslash.
The feature
By passing
extras={'breaks': {'on_backslash': True}}, users can now use backslashes to insert hard breaks, an example of which can be found in the break_on_backslash test case.Implementation
This has been implemented via a new
breaksextra, which contains this new functionality as well as the oldbreak-on-newlinefunctionality. The old extra name has been kept as an alias, so the two following examples are equivalent:This was done because I felt that having separate
break-on-*extras was unnecessary and that grouping these similar extras made sense.