diff options
-rw-r--r-- | README | 9 | ||||
-rw-r--r-- | changelog | 5 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/Markdown.hs | 8 | ||||
-rw-r--r-- | tests/markdown-reader-more.native | 4 | ||||
-rw-r--r-- | tests/markdown-reader-more.txt | 5 |
5 files changed, 25 insertions, 6 deletions
@@ -463,7 +463,14 @@ which allows only the following characters to be backslash-escaped: \`*_{}[]()>#+-.! A backslash-escaped space is parsed as a nonbreaking space. It will -appear in TeX output as '~' and in HTML and XML as '\ ' or '\ '. +appear in TeX output as '`~`' and in HTML and XML as '`\ `' or +'`\ `'. + +A backslash-escaped newline (i.e. a backslash occurring at the end of +a line) is parsed as a hard line break. It will appear in TeX output as +'`\\`' and in HTML as '`<br />`'. This is a nice alternative to +markdown's "invisible" way of indicating hard line breaks using +two trailing spaces on a line. Subscripts and superscripts --------------------------- @@ -15,6 +15,11 @@ pandoc (1.3) to use for indented code blocks. (Thanks to buttock for the patch; resolves Issue #87.) + * Treat a backslash followed by a newline as a hard line break + in markdown. Resolves Issue #154. This is a nice alternative + to markdown's "invisible" way of indicating hardline breaks + using lines that end with two spaces. + * Improved performance of markdown reader by ~10% by eliminating the need for a separate parsing pass for notes. Raw notes are now stored on the first pass (which parses diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 4f0d1b6ad..c6926e3c1 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -863,10 +863,10 @@ escapedChar = do result <- option '\\' $ if stateStrict state then oneOf "\\`*_{}[]()>#+-.!~" else satisfy (not . isAlphaNum) - let result' = if result == ' ' - then '\160' -- '\ ' is a nonbreaking space - else result - return $ Str [result'] + return $ case result of + ' ' -> Str "\160" -- "\ " is a nonbreaking space + '\n' -> LineBreak -- "\[newline]" is a linebreak + _ -> Str [result] ltSign :: GenParser Char ParserState Inline ltSign = do diff --git a/tests/markdown-reader-more.native b/tests/markdown-reader-more.native index 0e76ace86..e6665591a 100644 --- a/tests/markdown-reader-more.native +++ b/tests/markdown-reader-more.native @@ -19,5 +19,7 @@ Pandoc (Meta [] [] "") , Header 2 [Str "Commented",Str "-",Str "out",Space,Str "list",Space,Str "item"] , BulletList [ [ Plain [Str "one"] - , RawHtml "<!--\n- two\n-->" ], [ Plain [Str "three"] ] ] ] + , RawHtml "<!--\n- two\n-->" ], [ Plain [Str "three"] ] ] +, Header 2 [Str "Backslash",Space,Str "newline"] +, Para [Str "hi",LineBreak,Str "there"] ] diff --git a/tests/markdown-reader-more.txt b/tests/markdown-reader-more.txt index 02b425e11..4689ee84a 100644 --- a/tests/markdown-reader-more.txt +++ b/tests/markdown-reader-more.txt @@ -59,3 +59,8 @@ $\$2 + \$3$ --> - three +## Backslash newline + +hi\ +there + |