diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 5e966a17e..e1c481311 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1451,6 +1451,7 @@ inline = choice [ whitespace , autoLink , spanHtml , rawHtmlInline + , escapedNewline , escapedChar , rawLaTeXInline' , exampleRef @@ -1467,16 +1468,20 @@ escapedChar' = try $ do (guardEnabled Ext_all_symbols_escapable >> satisfy (not . isAlphaNum)) <|> (guardEnabled Ext_angle_brackets_escapable >> oneOf "\\`*_{}[]()>#+-.!~\"<>") - <|> (guardEnabled Ext_escaped_line_breaks >> char '\n') <|> oneOf "\\`*_{}[]()>#+-.!~\"" +escapedNewline :: PandocMonad m => MarkdownParser m (F Inlines) +escapedNewline = try $ do + guardEnabled Ext_escaped_line_breaks + char '\\' + lookAhead (char '\n') -- don't consume the newline (see #3730) + return $ return B.linebreak + escapedChar :: PandocMonad m => MarkdownParser m (F Inlines) escapedChar = do result <- escapedChar' case result of ' ' -> return $ return $ B.str "\160" -- "\ " is a nonbreaking space - '\n' -> guardEnabled Ext_escaped_line_breaks >> - return (return B.linebreak) -- "\[newline]" is a linebreak _ -> return $ return $ B.str [result] ltSign :: PandocMonad m => MarkdownParser m (F Inlines) diff --git a/test/command/3730.md b/test/command/3730.md new file mode 100644 index 000000000..fbc06cbce --- /dev/null +++ b/test/command/3730.md @@ -0,0 +1,21 @@ +```` +% pandoc +nice line\ +``` +code +``` +^D +

nice line
+

+
code
+```` + +``` +% pandoc +# hi\ +there +^D +

hi
+

+

there

+``` diff --git a/test/fb2/titles.fb2 b/test/fb2/titles.fb2 index 9e8d47e36..0a3b1404e 100644 --- a/test/fb2/titles.fb2 +++ b/test/fb2/titles.fb2 @@ -1,3 +1,3 @@ -pandoc<p />

<p>Simple title</p>

This example tests if Pandoc doesn’t insert forbidden elements in FictionBook titles.

<p>Emphasized Strong Title</p>
<p>Title with</p><empty-line /><p>line break</p>
+pandoc<p />

<p>Simple title</p>

This example tests if Pandoc doesn’t insert forbidden elements in FictionBook titles.

<p>Emphasized Strong Title</p>
diff --git a/test/fb2/titles.markdown b/test/fb2/titles.markdown index cc3d0e0d0..1eaf2ccd5 100644 --- a/test/fb2/titles.markdown +++ b/test/fb2/titles.markdown @@ -4,7 +4,3 @@ This example tests if Pandoc doesn't insert forbidden elements in FictionBook ti # *Emphasized* **Strong** Title -# Title with\ -line break - -