Markdown reader: better handling of paragraph in div.
Previously text that ended a div would be parsed as Plain unless there was a blank line before the closing div tag. Test case: <div class="first"> This is a paragraph. This is another paragraph. </div> Closes #1591.
This commit is contained in:
parent
6cf9ab7855
commit
598d3ee23b
14 changed files with 32 additions and 13 deletions
|
@ -927,6 +927,12 @@ para = try $ do
|
|||
<|> (guardDisabled Ext_blank_before_header >> () <$ lookAhead header)
|
||||
<|> (guardEnabled Ext_lists_without_preceding_blankline >>
|
||||
() <$ lookAhead listStart)
|
||||
<|> do guardEnabled Ext_native_divs
|
||||
inHtmlBlock <- stateInHtmlBlock <$> getState
|
||||
case inHtmlBlock of
|
||||
Just "div" -> () <$
|
||||
lookAhead (htmlTag (~== TagClose "div"))
|
||||
_ -> mzero
|
||||
return $ do
|
||||
result' <- result
|
||||
case B.toList result' of
|
||||
|
@ -1611,6 +1617,7 @@ endline = try $ do
|
|||
guardEnabled Ext_blank_before_header <|> notFollowedBy (char '#') -- atx header
|
||||
guardDisabled Ext_backtick_code_blocks <|>
|
||||
notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
|
||||
notFollowedByHtmlCloser
|
||||
(eof >> return mempty)
|
||||
<|> (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak))
|
||||
<|> (guardEnabled Ext_ignore_line_breaks >> return mempty)
|
||||
|
|
|
@ -266,10 +266,10 @@ tests = [ testGroup "inline code"
|
|||
, testGroup "lists"
|
||||
[ "issue #1154" =:
|
||||
" - <div>\n first div breaks\n </div>\n\n <button>if this button exists</button>\n\n <div>\n with this div too.\n </div>\n"
|
||||
=?> bulletList [divWith nullAttr (plain $ text "first div breaks") <>
|
||||
=?> bulletList [divWith nullAttr (para $ text "first div breaks") <>
|
||||
rawBlock "html" "<button>" <>
|
||||
plain (text "if this button exists") <>
|
||||
rawBlock "html" "</button>" <>
|
||||
divWith nullAttr (plain $ text "with this div too.")]
|
||||
divWith nullAttr (para $ text "with this div too.")]
|
||||
]
|
||||
]
|
||||
|
|
|
@ -230,7 +230,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
|
|||
,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
|
||||
,Div ("",[],[]) [Plain [Str "foo"]]
|
||||
,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
|
||||
,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "foo"]]],Div ("",[],[]) [Plain [Str "bar"]]]
|
||||
,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Para [Str "foo"]]],Div ("",[],[]) [Plain [Str "bar"]]]
|
||||
,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
|
||||
,RawBlock (Format "html") "<table>"
|
||||
,RawBlock (Format "html") "<tr>"
|
||||
|
@ -244,7 +244,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
|
|||
,RawBlock (Format "html") "</table>"
|
||||
,RawBlock (Format "html") "<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>"
|
||||
,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
|
||||
,Div ("",[],[]) [Plain [Str "foo"]]
|
||||
,Div ("",[],[]) [Para [Str "foo"]]
|
||||
,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
|
||||
,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
|
||||
,Para [Str "As",Space,Str "should",Space,Str "this:"]
|
||||
|
|
|
@ -378,6 +378,7 @@ foo
|
|||
And nested without indentation:
|
||||
|
||||
foo
|
||||
|
||||
bar
|
||||
Interpreted markdown in a table:
|
||||
|
||||
|
@ -386,6 +387,7 @@ And this is *strong*
|
|||
Here’s a simple block:
|
||||
|
||||
foo
|
||||
|
||||
This should be a code block, though:
|
||||
|
||||
-------
|
||||
|
|
|
@ -548,6 +548,7 @@ foo
|
|||
And nested without indentation:
|
||||
|
||||
foo
|
||||
|
||||
bar
|
||||
Interpreted markdown in a table:
|
||||
|
||||
|
@ -556,6 +557,7 @@ And this is {\bf strong}
|
|||
Here's a simple block:
|
||||
|
||||
foo
|
||||
|
||||
This should be a code block, though:
|
||||
|
||||
\starttyping
|
||||
|
|
|
@ -298,6 +298,7 @@ And nested without indentation:
|
|||
foo
|
||||
|
||||
|
||||
|
||||
bar
|
||||
|
||||
|
||||
|
@ -324,6 +325,7 @@ Here’s a simple block:
|
|||
|
||||
foo
|
||||
|
||||
|
||||
This should be a code block, though:
|
||||
|
||||
<code><div>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -328,7 +328,7 @@ foo
|
|||
<div>
|
||||
<div>
|
||||
<div>
|
||||
foo
|
||||
<p>foo</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
@ -349,7 +349,7 @@ And this is <strong>strong</strong>
|
|||
<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
|
||||
<p>Here’s a simple block:</p>
|
||||
<div>
|
||||
foo
|
||||
<p>foo</p>
|
||||
</div>
|
||||
<p>This should be a code block, though:</p>
|
||||
<pre><code><div>
|
||||
|
|
|
@ -1374,7 +1374,7 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
<Content>And nested without indentation:</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="">
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>foo</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
|
@ -1455,7 +1455,7 @@ These should not be escaped: \$ \\ \> \[ \{</Content>
|
|||
<Content>Here’s a simple block:</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
</ParagraphStyleRange>
|
||||
<ParagraphStyleRange AppliedParagraphStyle="">
|
||||
<ParagraphStyleRange AppliedParagraphStyle="ParagraphStyle/Paragraph">
|
||||
<CharacterStyleRange AppliedCharacterStyle="$ID/NormalCharacterStyle">
|
||||
<Content>foo</Content>
|
||||
</CharacterStyleRange><Br />
|
||||
|
|
|
@ -450,6 +450,7 @@ Simple block on one line:
|
|||
foo
|
||||
.PP
|
||||
And nested without indentation:
|
||||
.PP
|
||||
foo
|
||||
bar
|
||||
.PP
|
||||
|
@ -458,6 +459,7 @@ This is \f[I]emphasized\f[]
|
|||
And this is \f[B]strong\f[]
|
||||
.PP
|
||||
Here's a simple block:
|
||||
.PP
|
||||
foo
|
||||
.PP
|
||||
This should be a code block, though:
|
||||
|
|
|
@ -325,6 +325,7 @@ And nested without indentation:
|
|||
|
||||
foo
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
@ -354,6 +355,7 @@ Here’s a simple block:
|
|||
|
||||
foo
|
||||
|
||||
|
||||
</div>
|
||||
This should be a code block, though:
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
|
|||
,Para [Str "Simple",Space,Str "block",Space,Str "on",Space,Str "one",Space,Str "line:"]
|
||||
,Div ("",[],[]) [Plain [Str "foo"]]
|
||||
,Para [Str "And",Space,Str "nested",Space,Str "without",Space,Str "indentation:"]
|
||||
,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Plain [Str "foo"]]],Div ("",[],[]) [Plain [Str "bar"]]]
|
||||
,Div ("",[],[]) [Div ("",[],[]) [Div ("",[],[]) [Para [Str "foo"]]],Div ("",[],[]) [Plain [Str "bar"]]]
|
||||
,Para [Str "Interpreted",Space,Str "markdown",Space,Str "in",Space,Str "a",Space,Str "table:"]
|
||||
,RawBlock (Format "html") "<table>"
|
||||
,RawBlock (Format "html") "<tr>"
|
||||
|
@ -244,7 +244,7 @@ Pandoc (Meta {unMeta = fromList [("author",MetaList [MetaInlines [Str "John",Spa
|
|||
,RawBlock (Format "html") "</table>"
|
||||
,RawBlock (Format "html") "<script type=\"text/javascript\">document.write('This *should not* be interpreted as markdown');</script>"
|
||||
,Para [Str "Here\8217s",Space,Str "a",Space,Str "simple",Space,Str "block:"]
|
||||
,Div ("",[],[]) [Plain [Str "foo"]]
|
||||
,Div ("",[],[]) [Para [Str "foo"]]
|
||||
,Para [Str "This",Space,Str "should",Space,Str "be",Space,Str "a",Space,Str "code",Space,Str "block,",Space,Str "though:"]
|
||||
,CodeBlock ("",[],[]) "<div>\n foo\n</div>"
|
||||
,Para [Str "As",Space,Str "should",Space,Str "this:"]
|
||||
|
|
|
@ -208,13 +208,13 @@ These should not be escaped: \\$ \\\\ \\> \\[ \\\{\par}
|
|||
{\pard \ql \f0 \sa180 \li0 \fi0 Simple block on one line:\par}
|
||||
{\pard \ql \f0 \sa0 \li0 \fi0 foo\par}
|
||||
{\pard \ql \f0 \sa180 \li0 \fi0 And nested without indentation:\par}
|
||||
{\pard \ql \f0 \sa0 \li0 \fi0 foo\par}
|
||||
{\pard \ql \f0 \sa180 \li0 \fi0 foo\par}
|
||||
{\pard \ql \f0 \sa0 \li0 \fi0 bar\par}
|
||||
{\pard \ql \f0 \sa180 \li0 \fi0 Interpreted markdown in a table:\par}
|
||||
{\pard \ql \f0 \sa0 \li0 \fi0 This is {\i emphasized}\par}
|
||||
{\pard \ql \f0 \sa0 \li0 \fi0 And this is {\b strong}\par}
|
||||
{\pard \ql \f0 \sa180 \li0 \fi0 Here\u8217's a simple block:\par}
|
||||
{\pard \ql \f0 \sa0 \li0 \fi0 foo\par}
|
||||
{\pard \ql \f0 \sa180 \li0 \fi0 foo\par}
|
||||
{\pard \ql \f0 \sa180 \li0 \fi0 This should be a code block, though:\par}
|
||||
{\pard \ql \f0 \sa180 \li0 \fi0 \f1 <div>\line
|
||||
foo\line
|
||||
|
|
|
@ -367,6 +367,7 @@ And nested without indentation:
|
|||
|
||||
foo
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
@ -400,6 +401,7 @@ Here's a simple block:
|
|||
|
||||
foo
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
This should be a code block, though:
|
||||
|
|
Loading…
Reference in a new issue