git.iko.soy/typeable/pandoc
on master help sign in
Don't allow backslash + newline to affect block structure.
b466152John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+8−3
@@ -1451,6 +1451,7 @@ inline = choice [ whitespace
1451 , autoLink
1451 , autoLink
1452 , spanHtml
1452 , spanHtml
1453 , rawHtmlInline
1453 , rawHtmlInline
1454+ , escapedNewline
1454 , escapedChar
1455 , escapedChar
1455 , rawLaTeXInline'
1456 , rawLaTeXInline'
1456 , exampleRef
1457 , exampleRef
@@ -1467,16 +1468,20 @@ escapedChar' = try $ do
1467 (guardEnabled Ext_all_symbols_escapable >> satisfy (not . isAlphaNum))
1468 (guardEnabled Ext_all_symbols_escapable >> satisfy (not . isAlphaNum))
1468 <|> (guardEnabled Ext_angle_brackets_escapable >>
1469 <|> (guardEnabled Ext_angle_brackets_escapable >>
1469 oneOf "\\`*_{}[]()>#+-.!~\"<>")
1470 oneOf "\\`*_{}[]()>#+-.!~\"<>")
1470− <|> (guardEnabled Ext_escaped_line_breaks >> char '\n')
1471 <|> oneOf "\\`*_{}[]()>#+-.!~\""
1471 <|> oneOf "\\`*_{}[]()>#+-.!~\""
1472
1472
1473+escapedNewline :: PandocMonad m => MarkdownParser m (F Inlines)
1474+escapedNewline = try $ do
1475+ guardEnabled Ext_escaped_line_breaks
1476+ char '\\'
1477+ lookAhead (char '\n') -- don't consume the newline (see #3730)
1478+ return $ return B.linebreak
1479+
1473escapedChar :: PandocMonad m => MarkdownParser m (F Inlines)
1480escapedChar :: PandocMonad m => MarkdownParser m (F Inlines)
1474escapedChar = do
1481escapedChar = do
1475 result <- escapedChar'
1482 result <- escapedChar'
1476 case result of
1483 case result of
1477 ' ' -> return $ return $ B.str "\160" -- "\ " is a nonbreaking space
1484 ' ' -> return $ return $ B.str "\160" -- "\ " is a nonbreaking space
1478− '\n' -> guardEnabled Ext_escaped_line_breaks >>
1479− return (return B.linebreak) -- "\[newline]" is a linebreak
1480 _ -> return $ return $ B.str [result]
1485 _ -> return $ return $ B.str [result]
1481
1486
1482ltSign :: PandocMonad m => MarkdownParser m (F Inlines)
1487ltSign :: PandocMonad m => MarkdownParser m (F Inlines)
test/command/3730.mdnew file+21
@@ -0,0 +1,21 @@
1+````
2+% pandoc
3+nice line\
4+```
5+code
6+```
7+^D
8+<p>nice line<br />
9+</p>
10+<pre><code>code</code></pre>
11+````
12+
13+```
14+% pandoc
15+# hi\
16+there
17+^D
18+<h1 id="hi">hi<br />
19+</h1>
20+<p>there</p>
21+```
test/fb2/titles.fb2+1−1
@@ -1,3 +1,3 @@
1<?xml version="1.0" encoding="UTF-8"?>
1<?xml version="1.0" encoding="UTF-8"?>
2−<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><title><p>Simple title</p></title><p>This example tests if Pandoc doesn’t insert forbidden elements in FictionBook titles.</p></section><section><title><p>Emphasized Strong Title</p></title></section><section><title><p>Title with</p><empty-line /><p>line break</p></title></section></body></FictionBook>
2+<FictionBook xmlns="http://www.gribuser.ru/xml/fictionbook/2.0" xmlns:l="http://www.w3.org/1999/xlink"><description><title-info /><document-info><program-used>pandoc</program-used></document-info></description><body><title><p /></title><annotation><p></p></annotation><section><title><p>Simple title</p></title><p>This example tests if Pandoc doesn’t insert forbidden elements in FictionBook titles.</p></section><section><title><p>Emphasized Strong Title</p></title></section></body></FictionBook>
3
3
test/fb2/titles.markdown−4
@@ -4,7 +4,3 @@ This example tests if Pandoc doesn't insert forbidden elements in FictionBook ti
4
4
5# *Emphasized* **Strong** Title
5# *Emphasized* **Strong** Title
6
6
7−# Title with\
8−line break
9−
10−