Fenced divs: ensure that paragraph at end doesn't become Plain.
Added test case.
This commit is contained in:
parent
312db3b851
commit
513b16a71b
3 changed files with 31 additions and 11 deletions
14
MANUAL.txt
14
MANUAL.txt
|
@ -3080,10 +3080,12 @@ starts with a fence containing at least three consecutive
|
|||
colons plus some attributes. The attributes may optionally
|
||||
be followed by another string of consecutive colons.
|
||||
The attribute syntax is exactly as in fenced code blocks (see
|
||||
[Extension-fenced_code_attributes], above). The Div ends with
|
||||
another line containing a string of at least three consecutive
|
||||
colons. The fenced Div should be separated by blank lines from
|
||||
preceding and following blocks.
|
||||
[Extension-fenced_code_attributes], above). As with fenced
|
||||
code blocks, one can use either attributes in curly braces
|
||||
or a single unbraced word, which will be treated as a class
|
||||
name. The Div ends with another line containing a string of at
|
||||
least three consecutive colons. The fenced Div should be
|
||||
separated by blank lines from preceding and following blocks.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -3096,13 +3098,13 @@ Example:
|
|||
Fenced divs can be nested. Opening fences are distinguished
|
||||
because they *must* have attributes:
|
||||
|
||||
::: Warning
|
||||
::: Warning ::::::
|
||||
This is a warning.
|
||||
|
||||
::: Danger
|
||||
This is a warning within a warning.
|
||||
:::
|
||||
:::
|
||||
::::::::::::::::::
|
||||
|
||||
#### Extension: `raw_tex` ####
|
||||
|
||||
|
|
|
@ -1027,6 +1027,11 @@ para = try $ do
|
|||
Just "div" -> () <$
|
||||
lookAhead (htmlTag (~== TagClose "div"))
|
||||
_ -> mzero
|
||||
<|> do guardEnabled Ext_fenced_divs
|
||||
divLevel <- stateFencedDivLevel <$> getState
|
||||
if divLevel > 0
|
||||
then lookAhead divFenceEnd
|
||||
else mzero
|
||||
return $ do
|
||||
result' <- result
|
||||
case B.toList result' of
|
||||
|
@ -1689,7 +1694,7 @@ endline = try $ do
|
|||
notFollowedBy (() <$ (lookAhead (char '`') >> codeBlockFenced))
|
||||
guardDisabled Ext_fenced_divs <|>
|
||||
do divLevel <- stateFencedDivLevel <$> getState
|
||||
guard (divLevel < 1) <|> notFollowedBy fenceEnd
|
||||
guard (divLevel < 1) <|> notFollowedBy divFenceEnd
|
||||
notFollowedByHtmlCloser
|
||||
(eof >> return mempty)
|
||||
<|> (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak))
|
||||
|
@ -1946,12 +1951,12 @@ divFenced = try $ do
|
|||
skipMany (char ':')
|
||||
blankline
|
||||
updateState $ \st -> st{ stateFencedDivLevel = stateFencedDivLevel st + 1 }
|
||||
bs <- mconcat <$> manyTill block fenceEnd
|
||||
bs <- mconcat <$> manyTill block divFenceEnd
|
||||
updateState $ \st -> st{ stateFencedDivLevel = stateFencedDivLevel st - 1 }
|
||||
return $ B.divWith attribs <$> bs
|
||||
|
||||
fenceEnd :: PandocMonad m => MarkdownParser m ()
|
||||
fenceEnd = try $ do
|
||||
divFenceEnd :: PandocMonad m => MarkdownParser m ()
|
||||
divFenceEnd = try $ do
|
||||
nonindentSpaces
|
||||
string ":::"
|
||||
skipMany (char ':')
|
||||
|
|
|
@ -17,7 +17,7 @@ nested div
|
|||
[[Plain [Str "list"]]
|
||||
,[Plain [Str "another"]]]
|
||||
,Div ("myid",["class"],[("key","val")])
|
||||
[Plain [Str "nested",Space,Str "div"]]]]
|
||||
[Para [Str "nested",Space,Str "div"]]]]
|
||||
```
|
||||
|
||||
```
|
||||
|
@ -28,3 +28,16 @@ bar
|
|||
^D
|
||||
[Para [Str "foo",SoftBreak,Str ":::",SoftBreak,Str "bar"]]
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -t native
|
||||
::::: Warning
|
||||
Here is a paragraph.
|
||||
|
||||
And another.
|
||||
:::::
|
||||
^D
|
||||
[Div ("",["Warning"],[])
|
||||
[Para [Str "Here",Space,Str "is",Space,Str "a",Space,Str "paragraph."]
|
||||
,Para [Str "And",Space,Str "another."]]]
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue