diff --git a/src/Djot.hs b/src/Djot.hs index a7847be..323aeb1 100644 --- a/src/Djot.hs +++ b/src/Djot.hs @@ -893,9 +893,8 @@ image = do url <- inlineDestination pure $ Image {altText, url, title = Nothing, misc_attrs = mempty}, do - -- the IR has no reference image, so the label stands in for the url label <- referenceLabel - pure $ Image {altText, url = if T.null label then altText else label, title = Nothing, misc_attrs = mempty} + pure $ ReferenceImage {altText, label = if T.null label then altText else label, attrs = mempty} ] -- | @(url)@, with line endings inside the url removed as djot specifies. @@ -1000,6 +999,7 @@ plainOf = T.concat . map go go (Link {linkText}) = plainOf linkText go (ReferenceLink {linkText}) = plainOf linkText go (Image {altText}) = altText + go (ReferenceImage {altText}) = altText go (HTMLInline {inline_html_content}) = inline_html_content go (Superscript content _) = plainOf content go (Subscript content _) = plainOf content @@ -1034,6 +1034,7 @@ applyAttrs element extra = case element of Link {linkText, url, title, misc_attrs} -> Link {linkText, url, title, misc_attrs = misc_attrs <> extra} ReferenceLink {linkText, label, attrs} -> ReferenceLink {linkText, label, attrs = attrs <> extra} Image {altText, url, title, misc_attrs} -> Image {altText, url, title, misc_attrs = misc_attrs <> extra} + ReferenceImage {altText, label, attrs} -> ReferenceImage {altText, label, attrs = attrs <> extra} FootnoteReference {label, attrs} -> FootnoteReference {label, attrs = attrs <> extra} -- anything else (plain text in particular) becomes a span carrying the attrs other -> Span [other] extra diff --git a/src/IR.hs b/src/IR.hs index 894e6f5..b85b19b 100644 --- a/src/IR.hs +++ b/src/IR.hs @@ -90,6 +90,13 @@ data InlineText title :: Maybe Text, misc_attrs :: Attrs } + | -- the image equivalent of ReferenceLink, url comes from a RefDef with a + -- matching label + ReferenceImage + { altText :: Text, + label :: Text, + attrs :: Attrs + } | -- Markdown only DJOT uses RawInline HTMLInline {inline_html_content :: Text} | Superscript [InlineText] Attrs