git.iko.soy/typeable/pandoc
on master help sign in
Markdown writer: be sure implicit figures work in list contexts.
8632526John MacFarlane
src/Text/Pandoc/Readers/Markdown.hs+13−11
@@ -1039,7 +1039,18 @@ normalDefinitionList = do
1039para :: PandocMonad m => MarkdownParser m (F Blocks)
1039para :: PandocMonad m => MarkdownParser m (F Blocks)
1040para = try $ do
1040para = try $ do
1041 exts <- getOption readerExtensions
1041 exts <- getOption readerExtensions
1042+ let implicitFigures x
1043+ | extensionEnabled Ext_implicit_figures exts = do
1044+ x' <- x
1045+ case B.toList x' of
1046+ [Image attr alt (src,tit)]
1047+ | not (null alt) ->
1048+ -- the fig: at beginning of title indicates a figure
1049+ return $ B.singleton
1050+ $ Image attr alt (src,'f':'i':'g':':':tit)
1051+ _ -> return x'
1052+ | otherwise = x
1042− result <- trimInlinesF <$> inlines1
1053+ result <- implicitFigures . trimInlinesF <$> inlines1
1043 option (B.plain <$> result)
1054 option (B.plain <$> result)
1044 $ try $ do
1055 $ try $ do
1045 newline
1056 newline
@@ -1062,16 +1073,7 @@ para = try $ do
1062 if divLevel > 0
1073 if divLevel > 0
1063 then lookAhead divFenceEnd
1074 then lookAhead divFenceEnd
1064 else mzero
1075 else mzero
1065− return $ do
1076+ return $ B.para <$> result
1066− result' <- result
1067− case B.toList result' of
1068− [Image attr alt (src,tit)]
1069− | not (null alt) &&
1070− Ext_implicit_figures `extensionEnabled` exts ->
1071− -- the fig: at beginning of title indicates a figure
1072− return $ B.para $ B.singleton
1073− $ Image attr alt (src,'f':'i':'g':':':tit)
1074− _ -> return $ B.para result'
1075
1077
1076plain :: PandocMonad m => MarkdownParser m (F Blocks)
1078plain :: PandocMonad m => MarkdownParser m (F Blocks)
1077plain = fmap B.plain . trimInlinesF <$> inlines1
1079plain = fmap B.plain . trimInlinesF <$> inlines1