Added ignore_line_breaks markdown extension.

This causes intra-paragraph line breaks to be ignored,
rather than being treated as hard line breaks or spaces.
This is useful for some East Asian languages, where spaces
aren't used between words, but text is separated into lines
for readability.
This commit is contained in:
John MacFarlane 2013-07-17 15:38:56 -07:00
parent 7d75b913bd
commit 6c2e76ac61
3 changed files with 8 additions and 0 deletions

6
README
View file

@ -2416,6 +2416,12 @@ example, `markdown+hard_line_breaks` is markdown with hard line breaks.
Causes all newlines within a paragraph to be interpreted as hard line Causes all newlines within a paragraph to be interpreted as hard line
breaks instead of spaces. breaks instead of spaces.
**Extension: `ignore_line_breaks`**\
Causes newlines within a paragraph to be ignored, rather than being
treated as spaces or as hard line breaks. This option is intended for
use with East Asian languages where spaces are not used between words,
but text is divided into lines for readability.
**Extension: `tex_math_single_backslash`**\ **Extension: `tex_math_single_backslash`**\
Causes anything between `\(` and `\)` to be interpreted as inline Causes anything between `\(` and `\)` to be interpreted as inline
TeX math, and anything between `\[` and `\]` to be interpreted TeX math, and anything between `\[` and `\]` to be interpreted

View file

@ -92,6 +92,7 @@ data Extension =
| Ext_superscript -- ^ Superscript using ^this^ syntax | Ext_superscript -- ^ Superscript using ^this^ syntax
| Ext_subscript -- ^ Subscript using ~this~ syntax | Ext_subscript -- ^ Subscript using ~this~ syntax
| Ext_hard_line_breaks -- ^ All newlines become hard line breaks | Ext_hard_line_breaks -- ^ All newlines become hard line breaks
| Ext_ignore_line_breaks -- ^ Newlines in paragraphs are ignored
| Ext_literate_haskell -- ^ Enable literate Haskell conventions | Ext_literate_haskell -- ^ Enable literate Haskell conventions
| Ext_abbreviations -- ^ PHP markdown extra abbreviation definitions | Ext_abbreviations -- ^ PHP markdown extra abbreviation definitions
| Ext_auto_identifiers -- ^ Automatic identifiers for headers | Ext_auto_identifiers -- ^ Automatic identifiers for headers

View file

@ -1566,6 +1566,7 @@ endline = try $ do
notFollowedBy' bulletListStart notFollowedBy' bulletListStart
notFollowedBy' anyOrderedListStart notFollowedBy' anyOrderedListStart
(guardEnabled Ext_hard_line_breaks >> return (return B.linebreak)) (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak))
<|> (guardEnabled Ext_ignore_line_breaks >> return mempty)
<|> (return $ return B.space) <|> (return $ return B.space)
-- --