@@ -117,6 +117,12 @@ isBlank _ = False
117-- auxiliary functions
117-- auxiliary functions
120+-- | Succeeds when we're in list context.
121+inList :: MarkdownParser ()
123+ ctx <- stateParserContext <$> getState
124+ guard (ctx == ListItemState)
120isNull :: F Inlines -> Bool
126isNull :: F Inlines -> Bool
121isNull ils = B.isNull $ runF ils def
127isNull ils = B.isNull $ runF ils def
@@ -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
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:
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