Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the SimpleFigure in Readers #7611

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ source-repository-package
location: https://github.com/jgm/commonmark-hs.git
tag: 3cba9f874db7516f49d221a94171b4af010b5bea
subdir: commonmark-pandoc

2 changes: 1 addition & 1 deletion src/Text/Pandoc/Readers/HTML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ pFigure = try $ do
let caption = fromMaybe mempty mbcap
case B.toList <$> mbimg of
Just [Image attr _ (url, tit)] ->
return $ B.para $ B.imageWith attr url ("fig:" <> tit) caption
return $ B.simpleFigureWith attr caption url tit
_ -> mzero

pCodeBlock :: PandocMonad m => TagParser m Blocks
Expand Down
37 changes: 19 additions & 18 deletions src/Text/Pandoc/Readers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -935,8 +935,8 @@ environments = M.union (tableEnvironments blocks inline) $
, ("letter", env "letter" letterContents)
, ("minipage", env "minipage" $
skipopts *> spaces *> optional braced *> spaces *> blocks)
, ("figure", env "figure" $ skipopts *> figure)
, ("subfigure", env "subfigure" $ skipopts *> tok *> figure)
, ("figure", env "figure" $ skipopts *> Text.Pandoc.Readers.LaTeX.figure)
, ("subfigure", env "subfigure" $ skipopts *> tok *> Text.Pandoc.Readers.LaTeX.figure)
Comment on lines +938 to +939
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These qualifications won't be necessary until figure is added to Builder, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct

, ("center", divWith ("", ["center"], []) <$> env "center" blocks)
, ("quote", blockQuote <$> env "quote" blocks)
, ("quotation", blockQuote <$> env "quotation" blocks)
Expand Down Expand Up @@ -1095,24 +1095,25 @@ figure = try $ do

addImageCaption :: PandocMonad m => Blocks -> LP m Blocks
addImageCaption = walkM go
where go (Image attr@(_, cls, kvs) alt (src,tit))
where go p@(Para [Image attr@(_, cls, kvs) _ (src, tit)])
| not ("fig:" `T.isPrefixOf` tit) = do
st <- getState
let (alt', tit') = case sCaption st of
Just ils -> (toList ils, "fig:" <> tit)
Nothing -> (alt, tit)
attr' = case sLastLabel st of
Just lab -> (lab, cls, kvs)
Nothing -> attr
case attr' of
("", _, _) -> return ()
(ident, _, _) -> do
num <- getNextNumber sLastFigureNum
setState
st{ sLastFigureNum = num
, sLabels = M.insert ident
[Str (renderDottedNum num)] (sLabels st) }
return $ Image attr' alt' (src, tit')
case sCaption st of
Nothing -> return p
Just figureCaption -> do
let attr' = case sLastLabel st of
Just lab -> (lab, cls, kvs)
Nothing -> attr
case attr' of
("", _, _) -> return ()
(ident, _, _) -> do
num <- getNextNumber sLastFigureNum
setState
st{ sLastFigureNum = num
, sLabels = M.insert ident
[Str (renderDottedNum num)] (sLabels st) }

return $ SimpleFigure attr' (B.toList figureCaption) (src, tit)
go x = return x

coloredBlock :: PandocMonad m => Text -> LP m Blocks
Expand Down
27 changes: 13 additions & 14 deletions src/Text/Pandoc/Readers/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,19 +1013,18 @@ normalDefinitionList = do
para :: PandocMonad m => MarkdownParser m (F Blocks)
para = try $ do
exts <- getOption readerExtensions
let implicitFigures x
| extensionEnabled Ext_implicit_figures exts = do
x' <- x
case B.toList x' of
[Image attr alt (src,tit)]
| not (null alt) ->
-- the fig: at beginning of title indicates a figure
return $ B.singleton
$ Image attr alt (src, "fig:" <> tit)
_ -> return x'
| otherwise = x
result <- implicitFigures . trimInlinesF <$> inlines1
option (B.plain <$> result)

result <- trimInlinesF <$> inlines1
let figureOr constr inlns =
case B.toList inlns of
[Image attr figCaption (src, tit)]
| extensionEnabled Ext_implicit_figures exts
, not (null figCaption) -> do
B.simpleFigureWith attr (B.fromList figCaption) src tit

_ -> constr inlns

option (figureOr B.plain <$> result)
$ try $ do
newline
(mempty <$ blanklines)
Expand All @@ -1047,7 +1046,7 @@ para = try $ do
if divLevel > 0
then lookAhead divFenceEnd
else mzero
return $ B.para <$> result
return $ figureOr B.para <$> result

plain :: PandocMonad m => MarkdownParser m (F Blocks)
plain = fmap B.plain . trimInlinesF <$> inlines1
Expand Down
9 changes: 7 additions & 2 deletions src/Text/Pandoc/Readers/MediaWiki.hs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ para = do
contents <- trimInlines . mconcat <$> many1 inline
if F.all (==Space) contents
then return mempty
else return $ B.para contents
else case B.toList contents of
-- For the MediaWiki format all images are considered figures
[Image attr figureCaption (src, title)] ->
return $ B.simpleFigureWith
attr (B.fromList figureCaption) src title
Comment on lines +205 to +208
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate on "For the MediaWiki format all images are considered figures"? Is this a change in behavior? What motivates it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original (before I rewrote it using simple figure) code had that behavior and I kept it. I just implemented the behavior here (at lines ~205-208)

_ -> return $ B.para contents

table :: PandocMonad m => MWParser m Blocks
table = do
Expand Down Expand Up @@ -631,7 +636,7 @@ image = try $ do
let attr = ("", [], kvs)
caption <- (B.str fname <$ sym "]]")
<|> try (char '|' *> (mconcat <$> manyTill inline (sym "]]")))
return $ B.imageWith attr fname ("fig:" <> stringify caption) caption
return $ B.imageWith attr fname (stringify caption) caption
Comment on lines -634 to +639
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this change?

Copy link
Contributor Author

@argent0 argent0 Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to the previous one this is where the "For the MediaWiki format all images are considered figures" came from. The original code used the "fig:" prefix all the time as the deleted 634 line shows.

MediaWiki supports inline images: https://www.mediawiki.org/wiki/Help:Images

I just kept the old behavior. (but implemented it at lines ~206)

Copy link
Contributor Author

@argent0 argent0 Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch's version

$ pandoc -f mediawiki -t native
this [[File:example.jpg|caption]] is
[ Para
    [ Str "this"
    , Space
    , Image
        ( "" , [] , [] )
        [ Str "caption" ]
        ( "example.jpg" , "caption" )
    , Space
    , Str "is"
    ]
]

pandoc 2.14.1

$ pandoc -f mediawiki -t native foo.mediawiki
[Para [Str "this",Space,Image ("",[],[]) [Str "caption"] ("example.jpg","fig:caption"),Space,Str "is"]]

Notice the 'fig:' prefixing the caption.

It doesn't actually create a figure ([Para [Image ..]]) but it adds a superfluous (?) 'fig:'. This patch omits the fig:

So the comment should be removed\

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks for clarifying, this makes sense.


imageOption :: PandocMonad m => MWParser m Text
imageOption = try $ char '|' *> opt
Expand Down
19 changes: 10 additions & 9 deletions src/Text/Pandoc/Readers/Org/Blocks.hs
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,16 @@ figure = try $ do
figCaption = fromMaybe mempty $ blockAttrCaption figAttrs
figKeyVals = blockAttrKeyValues figAttrs
attr = (figLabel, mempty, figKeyVals)
figTitle = (if isFigure then withFigPrefix else id) figName
in
B.para . B.imageWith attr imgSrc figTitle <$> figCaption

withFigPrefix :: Text -> Text
withFigPrefix cs =
if "fig:" `T.isPrefixOf` cs
then cs
else "fig:" <> cs
in if isFigure
then (\c ->
B.simpleFigureWith
attr c imgSrc (unstackFig figName)) <$> figCaption
else B.para . B.imageWith attr imgSrc figName <$> figCaption
unstackFig :: Text -> Text
unstackFig figName =
if "fig:" `T.isPrefixOf` figName
then T.drop 4 figName
else figName

-- | Succeeds if looking at the end of the current paragraph
endOfParagraph :: Monad m => OrgParser m ()
Expand Down
4 changes: 2 additions & 2 deletions src/Text/Pandoc/Readers/RST.hs
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,8 @@ directive' = do
"figure" -> do
(caption, legend) <- parseFromString' extractCaption body'
let src = escapeURI $ trim top
return $ B.para (B.imageWith (imgAttr "figclass") src "fig:"
caption) <> legend
return $ B.simpleFigureWith
(imgAttr "figclass") caption src "" <> legend
"image" -> do
let src = escapeURI $ trim top
let alt = B.str $ maybe "image" trim $ lookup "alt" fields
Expand Down
3 changes: 1 addition & 2 deletions src/Text/Pandoc/Writers/AsciiDoc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,8 @@ blockToAsciiDoc opts (Div (id',"section":_,_)
blockToAsciiDoc opts (Plain inlines) = do
contents <- inlineListToAsciiDoc opts inlines
return $ contents <> blankline
blockToAsciiDoc opts (Para [Image attr alternate (src,tgt)])
blockToAsciiDoc opts (SimpleFigure attr alternate (src, tit))
-- image::images/logo.png[Company logo, title="blah"]
| Just tit <- T.stripPrefix "fig:" tgt
= (\args -> "image::" <> args <> blankline) <$>
imageArguments opts attr alternate src tit
blockToAsciiDoc opts (Para inlines) = do
Expand Down
5 changes: 1 addition & 4 deletions src/Text/Pandoc/Writers/ConTeXt.hs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ blockToConTeXt (Div attr@(_,"section":_,_)
innerContents <- blockListToConTeXt xs
return $ header' $$ innerContents $$ footer'
blockToConTeXt (Plain lst) = inlineListToConTeXt lst
-- title beginning with fig: indicates that the image is a figure
blockToConTeXt (Para [Image attr txt (src,tgt)])
| Just _ <- T.stripPrefix "fig:" tgt
= do
blockToConTeXt (SimpleFigure attr txt (src, _)) = do
capt <- inlineListToConTeXt txt
img <- inlineToConTeXt (Image attr txt (src, ""))
let (ident, _, _) = attr
Expand Down
5 changes: 2 additions & 3 deletions src/Text/Pandoc/Writers/Docbook.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ViewPatterns #-}
{- |
Module : Text.Pandoc.Writers.Docbook
Copyright : Copyright (C) 2006-2021 John MacFarlane
Expand Down Expand Up @@ -187,7 +186,7 @@ blockToDocbook opts (Div (id',"section":_,_) (Header lvl (_,_,attrs) ils : xs))
-- standalone documents will include them in the template.
then [("xmlns", "http://docbook.org/ns/docbook"),("xmlns:xlink", "http://www.w3.org/1999/xlink")]
else []

-- Populate miscAttr with Header.Attr.attributes, filtering out non-valid DocBook section attributes, id, and xml:id
miscAttr = filter (isSectionAttr version) attrs
attribs = nsAttr <> idAttr <> miscAttr
Expand Down Expand Up @@ -232,7 +231,7 @@ blockToDocbook _ h@Header{} = do
return empty
blockToDocbook opts (Plain lst) = inlinesToDocbook opts lst
-- title beginning with fig: indicates that the image is a figure
blockToDocbook opts (Para [Image attr txt (src,T.stripPrefix "fig:" -> Just _)]) = do
blockToDocbook opts (SimpleFigure attr txt (src, _)) = do
alt <- inlinesToDocbook opts txt
let capt = if null txt
then empty
Expand Down
3 changes: 1 addition & 2 deletions src/Text/Pandoc/Writers/Docx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,7 @@ blockToOpenXML' opts (Plain lst) = do
then withParaProp prop block
else block
-- title beginning with fig: indicates that the image is a figure
blockToOpenXML' opts (Para [Image attr@(imgident,_,_) alt
(src,T.stripPrefix "fig:" -> Just tit)]) = do
blockToOpenXML' opts (SimpleFigure attr@(imgident, _, _) alt (src, tit)) = do
setFirstPara
fignum <- gets stNextFigureNum
unless (null alt) $ modify $ \st -> st{ stNextFigureNum = fignum + 1 }
Expand Down
4 changes: 1 addition & 3 deletions src/Text/Pandoc/Writers/DokuWiki.hs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ blockToDokuWiki opts (Plain inlines) =

-- title beginning with fig: indicates that the image is a figure
-- dokuwiki doesn't support captions - so combine together alt and caption into alt
blockToDokuWiki opts (Para [Image attr txt (src,tgt)])
| Just tit <- T.stripPrefix "fig:" tgt
= do
blockToDokuWiki opts (SimpleFigure attr txt (src, tit)) = do
capt <- if null txt
then return ""
else (" " <>) `fmap` inlineListToDokuWiki opts txt
Expand Down
5 changes: 2 additions & 3 deletions src/Text/Pandoc/Writers/FB2.hs
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,8 @@ blockToXml :: PandocMonad m => Block -> FBM m [Content]
blockToXml (Plain ss) = cMapM toXml ss -- FIXME: can lead to malformed FB2
blockToXml (Para [Math DisplayMath formula]) = insertMath NormalImage formula
-- title beginning with fig: indicates that the image is a figure
blockToXml (Para [Image atr alt (src,tgt)])
| Just tit <- T.stripPrefix "fig:" tgt
= insertImage NormalImage (Image atr alt (src,tit))
blockToXml (SimpleFigure atr alt (src, tit)) =
insertImage NormalImage (Image atr alt (src,tit))
blockToXml (Para ss) = list . el "p" <$> cMapM toXml ss
blockToXml (CodeBlock _ s) = return . spaceBeforeAfter .
map (el "p" . el "code") . T.lines $ s
Expand Down
4 changes: 2 additions & 2 deletions src/Text/Pandoc/Writers/HTML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ blockToHtmlInner opts (Para [Image attr@(_,classes,_) txt (src,tit)])
inlineToHtml opts (Image attr txt (src, tit))
_ -> figure opts attr txt (src, tit)
-- title beginning with fig: indicates that the image is a figure
blockToHtmlInner opts (Para [Image attr txt (s,T.stripPrefix "fig:" -> Just tit)]) =
figure opts attr txt (s,tit)
blockToHtmlInner opts (SimpleFigure attr caption (src, title)) =
figure opts attr caption (src, title)
blockToHtmlInner opts (Para lst) = do
contents <- inlineListToHtml opts lst
case contents of
Expand Down
3 changes: 1 addition & 2 deletions src/Text/Pandoc/Writers/Haddock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ blockToHaddock opts (Plain inlines) = do
contents <- inlineListToHaddock opts inlines
return $ contents <> cr
-- title beginning with fig: indicates figure
blockToHaddock opts (Para [Image attr alt (src,tgt)])
| Just tit <- T.stripPrefix "fig:" tgt
blockToHaddock opts (SimpleFigure attr alt (src, tit))
= blockToHaddock opts (Para [Image attr alt (src,tit)])
blockToHaddock opts (Para inlines) =
-- TODO: if it contains linebreaks, we need to use a @...@ block
Expand Down
6 changes: 2 additions & 4 deletions src/Text/Pandoc/Writers/ICML.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE ViewPatterns #-}

{- |
Module : Text.Pandoc.Writers.ICML
Expand Down Expand Up @@ -309,9 +308,8 @@ blocksToICML opts style lst = do
-- | Convert a Pandoc block element to ICML.
blockToICML :: PandocMonad m => WriterOptions -> Style -> Block -> WS m (Doc Text)
blockToICML opts style (Plain lst) = parStyle opts style "" lst
-- title beginning with fig: indicates that the image is a figure
blockToICML opts style (Para img@[Image _ txt (_,Text.stripPrefix "fig:" -> Just _)]) = do
figure <- parStyle opts (figureName:style) "" img
blockToICML opts style (SimpleFigure attr txt (src, tit)) = do
figure <- parStyle opts (figureName:style) "" [Image attr txt (src, tit)]
caption <- parStyle opts (imgCaptionName:style) "" txt
return $ intersperseBrs [figure, caption]
blockToICML opts style (Para lst) = parStyle opts (paragraphName:style) "" lst
Expand Down
4 changes: 1 addition & 3 deletions src/Text/Pandoc/Writers/JATS.hs
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,7 @@ blockToJATS opts (Header _ _ title) = do
return $ inTagsSimple "title" title'
-- No Plain, everything needs to be in a block-level tag
blockToJATS opts (Plain lst) = blockToJATS opts (Para lst)
-- title beginning with fig: indicates that the image is a figure
blockToJATS opts (Para [Image (ident,_,kvs) txt
(src,T.stripPrefix "fig:" -> Just tit)]) = do
blockToJATS opts (SimpleFigure (ident, _, kvs) txt (src, tit)) = do
alt <- inlinesToJATS opts txt
let (maintype, subtype) = imageMimeType src kvs
let capt = if null txt
Expand Down
5 changes: 1 addition & 4 deletions src/Text/Pandoc/Writers/LaTeX.hs
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,7 @@ blockToLaTeX (Div (identifier,classes,kvs) bs) = do
wrapNotes <$> wrapDiv (identifier,classes,kvs) result
blockToLaTeX (Plain lst) =
inlineListToLaTeX lst
-- title beginning with fig: indicates that the image is a figure
blockToLaTeX (Para [Image attr@(ident, _, _) txt (src,tgt)])
| Just tit <- T.stripPrefix "fig:" tgt
= do
blockToLaTeX (SimpleFigure attr@(ident, _, _) txt (src, tit)) = do
(capt, captForLof, footnotes) <- getCaption inlineListToLaTeX True txt
lab <- labelFor ident
let caption = "\\caption" <> captForLof <> braces capt <> lab
Expand Down
6 changes: 2 additions & 4 deletions src/Text/Pandoc/Writers/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ViewPatterns #-}
{- |
Module : Text.Pandoc.Writers.Markdown
Copyright : Copyright (C) 2006-2021 John MacFarlane
Expand Down Expand Up @@ -364,14 +363,13 @@ blockToMarkdown' opts (Plain inlines) = do
_ -> inlines
contents <- inlineListToMarkdown opts inlines'
return $ contents <> cr
-- title beginning with fig: indicates figure
blockToMarkdown' opts (Para [Image attr alt (src,tgt@(T.stripPrefix "fig:" -> Just tit))])
blockToMarkdown' opts (SimpleFigure attr alt (src, tit))
| isEnabled Ext_raw_html opts &&
not (isEnabled Ext_link_attributes opts || isEnabled Ext_attributes opts) &&
attr /= nullAttr = -- use raw HTML
(<> blankline) . literal . T.strip <$>
writeHtml5String opts{ writerTemplate = Nothing }
(Pandoc nullMeta [Para [Image attr alt (src,tgt)]])
(Pandoc nullMeta [SimpleFigure attr alt (src, tit)])
| otherwise = blockToMarkdown opts (Para [Image attr alt (src,tit)])
blockToMarkdown' opts (Para inlines) =
(<> blankline) `fmap` blockToMarkdown opts (Plain inlines)
Expand Down
4 changes: 1 addition & 3 deletions src/Text/Pandoc/Writers/MediaWiki.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ViewPatterns #-}
{- |
Module : Text.Pandoc.Writers.MediaWiki
Copyright : Copyright (C) 2008-2021 John MacFarlane
Expand Down Expand Up @@ -89,8 +88,7 @@ blockToMediaWiki (Div attrs bs) = do
blockToMediaWiki (Plain inlines) =
inlineListToMediaWiki inlines

-- title beginning with fig: indicates that the image is a figure
blockToMediaWiki (Para [Image attr txt (src,T.stripPrefix "fig:" -> Just tit)]) = do
blockToMediaWiki (SimpleFigure attr txt (src, tit)) = do
capt <- inlineListToMediaWiki txt
img <- imageToMediaWiki attr
let opt = if T.null tit
Expand Down
3 changes: 1 addition & 2 deletions src/Text/Pandoc/Writers/OpenDocument.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternGuards #-}
{-# LANGUAGE ViewPatterns #-}
{- |
Module : Text.Pandoc.Writers.OpenDocument
Copyright : Copyright (C) 2008-2020 Andrea Rossato and John MacFarlane
Expand Down Expand Up @@ -377,7 +376,7 @@ blockToOpenDocument o = \case
Plain b -> if null b
then return empty
else inParagraphTags =<< inlinesToOpenDocument o b
Para [Image attr c (s,T.stripPrefix "fig:" -> Just t)] -> figure attr c s t
SimpleFigure attr c (s, t) -> figure attr c s t
Para b -> if null b &&
not (isEnabled Ext_empty_paragraphs o)
then return empty
Expand Down
4 changes: 1 addition & 3 deletions src/Text/Pandoc/Writers/Org.hs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ blockToOrg :: PandocMonad m
-> Org m (Doc Text)
blockToOrg (Div attr bs) = divToOrg attr bs
blockToOrg (Plain inlines) = inlineListToOrg inlines
-- title beginning with fig: indicates that the image is a figure
blockToOrg (Para [Image attr txt (src,tgt)])
| Just tit <- T.stripPrefix "fig:" tgt = do
blockToOrg (SimpleFigure attr txt (src, tit)) = do
capt <- if null txt
then return empty
else ("#+caption: " <>) `fmap` inlineListToOrg txt
Expand Down
Loading