git.iko.soy/typeable/pandoc
on master help sign in
Don't allow backslash + newline to affect block structure.

Note that as a result of this change, the following, which formerly produced a header with two lines separated by a line break, will now produce a header followed by a paragraph: # Hi\ there This may affect some existing documents that relied on this undocumented and unintended behavior. This change makes pandoc more consistent with other Markdown implementations, and with itself (since the two-space version of a line break doesn't work inside ATX headers, and neither version works inside Setext headers). Closes #3730.

commitb466152d6185750438f7355701ae68186692d65b authorJohn MacFarlane <jgm@berkeley.edu> dateSun 11 Jun 2017, 22:24 (9 years ago) parentd1da54a
4 files changed+30−8
src/Text/Pandoc/Readers/Markdown.hs+8−3 test/command/3730.md+21 test/fb2/titles.fb2+1−1 test/fb2/titles.markdown−4
src/Text/Pandoc/Readers/Markdown.hs+8−3
@@ -1451,6 +1451,7 @@ inline = choice [ whitespace
14511451 , autoLink
14521452 , spanHtml
14531453 , rawHtmlInline
1454+ , escapedNewline
14541455 , escapedChar
14551456 , rawLaTeXInline'
14561457 , exampleRef
@@ -1467,16 +1468,20 @@ escapedChar' = try $ do
14671468 (guardEnabled Ext_all_symbols_escapable >> satisfy (not . isAlphaNum))
14681469 <|> (guardEnabled Ext_angle_brackets_escapable >>
14691470 oneOf "\\`*_{}[]()>#+-.!~\"<>")
1470− <|> (guardEnabled Ext_escaped_line_breaks >> char '\n')
14711471 <|> oneOf "\\`*_{}[]()>#+-.!~\""
14721472
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+
14731480escapedChar :: PandocMonad m => MarkdownParser m (F Inlines)
14741481escapedChar = do
14751482 result <- escapedChar'
14761483 case result of
14771484 ' ' -> 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
14801485 _ -> return $ return $ B.str [result]
14811486
14821487ltSign :: 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 @@
11<?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>
33
test/fb2/titles.markdown−4
@@ -4,7 +4,3 @@ This example tests if Pandoc doesn't insert forbidden elements in FictionBook ti
44
55# *Emphasized* **Strong** Title
66
7−# Title with\
8−line break
9−
10−