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
This commit is contained in:
fiddlosopher 2009-12-05 05:33:24 +00:00
parent 94841b7602
commit 8671bc5a1b
5 changed files with 25 additions and 6 deletions

9
README
View file

@ -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
---------------------------

View file

@ -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

View file

@ -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

View file

@ -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"] ]

View file

@ -59,3 +59,8 @@ $\$2 + \$3$
-->
- three
## Backslash newline
hi\
there