git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Treat a backslash followed by a newline as hard linebreak.

Resolves Issue #154. git-svn-id: https://pandoc.googlecode.com/svn/trunk@1646 788f1e2b-df1e-0410-8736-df70ead52e1b

commit8671bc5a1be38f6555e34d7ccc542ebbe91f69fd authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateSat 5 Dec 2009, 05:33 (17 years ago) parent94841b7
5 files changed+25−6
README+8−1 changelog+5 src/Text/Pandoc/Readers/Markdown.hs+4−4 tests/markdown-reader-more.native+3−1 tests/markdown-reader-more.txt+5
README+8−1
@@ -463,7 +463,14 @@ which allows only the following characters to be backslash-escaped:
463463 \`*_{}[]()>#+-.!
464464
465465A backslash-escaped space is parsed as a nonbreaking space. It will
466−appear in TeX output as '~' and in HTML and XML as '\&#160;' or '\&nbsp;'.
466+appear in TeX output as '`~`' and in HTML and XML as '`\&#160;`' or
467+'`\&nbsp;`'.
468+
469+A backslash-escaped newline (i.e. a backslash occurring at the end of
470+a line) is parsed as a hard line break. It will appear in TeX output as
471+'`\\`' and in HTML as '`<br />`'. This is a nice alternative to
472+markdown's "invisible" way of indicating hard line breaks using
473+two trailing spaces on a line.
467474
468475Subscripts and superscripts
469476---------------------------
changelog+5
@@ -15,6 +15,11 @@ pandoc (1.3)
1515 to use for indented code blocks. (Thanks to buttock for the
1616 patch; resolves Issue #87.)
1717
18+ * Treat a backslash followed by a newline as a hard line break
19+ in markdown. Resolves Issue #154. This is a nice alternative
20+ to markdown's "invisible" way of indicating hardline breaks
21+ using lines that end with two spaces.
22+
1823 * Improved performance of markdown reader by ~10% by
1924 eliminating the need for a separate parsing pass for notes.
2025 Raw notes are now stored on the first pass (which parses
src/Text/Pandoc/Readers/Markdown.hs+4−4
@@ -863,10 +863,10 @@ escapedChar = do
863863 result <- option '\\' $ if stateStrict state
864864 then oneOf "\\`*_{}[]()>#+-.!~"
865865 else satisfy (not . isAlphaNum)
866− let result' = if result == ' '
867− then '\160' -- '\ ' is a nonbreaking space
868− else result
869− return $ Str [result']
866+ return $ case result of
867+ ' ' -> Str "\160" -- "\ " is a nonbreaking space
868+ '\n' -> LineBreak -- "\[newline]" is a linebreak
869+ _ -> Str [result]
870870
871871ltSign :: GenParser Char ParserState Inline
872872ltSign = do
tests/markdown-reader-more.native+3−1
@@ -19,5 +19,7 @@ Pandoc (Meta [] [] "")
1919, Header 2 [Str "Commented",Str "-",Str "out",Space,Str "list",Space,Str "item"]
2020, BulletList
2121 [ [ Plain [Str "one"]
22− , RawHtml "<!--\n- two\n-->" ], [ Plain [Str "three"] ] ] ]
22+ , RawHtml "<!--\n- two\n-->" ], [ Plain [Str "three"] ] ]
23+, Header 2 [Str "Backslash",Space,Str "newline"]
24+, Para [Str "hi",LineBreak,Str "there"] ]
2325
tests/markdown-reader-more.txt+5
@@ -59,3 +59,8 @@ $\$2 + \$3$
5959-->
6060- three
6161
62+## Backslash newline
63+
64+hi\
65+there
66+