git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1645 from neongreen/issue1636
43c1978John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+9−2
@@ -117,6 +117,12 @@ isBlank _ = False
117-- auxiliary functions
117-- auxiliary functions
118--
118--
119
119
120+-- | Succeeds when we're in list context.
121+inList :: MarkdownParser ()
122+inList = do
123+ ctx <- stateParserContext <$> getState
124+ guard (ctx == ListItemState)
125+
120isNull :: F Inlines -> Bool
126isNull :: F Inlines -> Bool
121isNull ils = B.isNull $ runF ils def
127isNull ils = B.isNull $ runF ils def
122
128
@@ -926,6 +932,8 @@ para = try $ do
926 <|> (guardEnabled Ext_backtick_code_blocks >> () <$ lookAhead codeBlockFenced)
932 <|> (guardEnabled Ext_backtick_code_blocks >> () <$ lookAhead codeBlockFenced)
927 <|> (guardDisabled Ext_blank_before_header >> () <$ lookAhead header)
933 <|> (guardDisabled Ext_blank_before_header >> () <$ lookAhead header)
928 <|> (guardEnabled Ext_lists_without_preceding_blankline >>
934 <|> (guardEnabled Ext_lists_without_preceding_blankline >>
935+ -- Avoid creating a paragraph in a nested list.
936+ notFollowedBy' inList >>
929 () <$ lookAhead listStart)
937 () <$ lookAhead listStart)
930 <|> do guardEnabled Ext_native_divs
938 <|> do guardEnabled Ext_native_divs
931 inHtmlBlock <- stateInHtmlBlock <$> getState
939 inHtmlBlock <- stateInHtmlBlock <$> getState
@@ -1610,8 +1618,7 @@ endline = try $ do
1610 newline
1618 newline
1611 notFollowedBy blankline
1619 notFollowedBy blankline
1612 -- parse potential list-starts differently if in a list:
1620 -- parse potential list-starts differently if in a list:
1613− st <- getState
1614− when (stateParserContext st == ListItemState) $ notFollowedBy listStart
1621+ notFollowedBy (inList >> listStart)
1615 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
1622 guardDisabled Ext_lists_without_preceding_blankline <|> notFollowedBy listStart
1616 guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
1623 guardEnabled Ext_blank_before_blockquote <|> notFollowedBy emailBlockQuoteStart
1617 guardEnabled Ext_blank_before_header <|> notFollowedBy (char '#') -- atx header
1624 guardEnabled Ext_blank_before_header <|> notFollowedBy (char '#') -- atx header
tests/Tests/Readers/Markdown.hs+12
@@ -20,6 +20,9 @@ markdownCDL :: String -> Pandoc
20markdownCDL = readMarkdown def { readerExtensions = Set.insert
20markdownCDL = readMarkdown def { readerExtensions = Set.insert
21 Ext_compact_definition_lists $ readerExtensions def }
21 Ext_compact_definition_lists $ readerExtensions def }
22
22
23+markdownGH :: String -> Pandoc
24+markdownGH = readMarkdown def { readerExtensions = githubMarkdownExtensions }
25+
23infix 4 =:
26infix 4 =:
24(=:) :: ToString c
27(=:) :: ToString c
25 => String -> (String, c) -> Test
28 => String -> (String, c) -> Test
@@ -271,5 +274,14 @@ tests = [ testGroup "inline code"
271 plain (text "if this button exists") <>
274 plain (text "if this button exists") <>
272 rawBlock "html" "</button>" <>
275 rawBlock "html" "</button>" <>
273 divWith nullAttr (para $ text "with this div too.")]
276 divWith nullAttr (para $ text "with this div too.")]
277+ , test markdownGH "issue #1636" $
278+ unlines [ "* a"
279+ , "* b"
280+ , "* c"
281+ , " * d" ]
282+ =?>
283+ bulletList [ plain "a"
284+ , plain "b"
285+ , plain "c" <> bulletList [plain "d"] ]
274 ]
286 ]
275 ]
287 ]