@@ -98,6 +98,7 @@ block = choice [ mempty <$ blanklines
98-- | Attributes that may be added to figures (like a name or caption).
98-- | Attributes that may be added to figures (like a name or caption).
99data BlockAttributes = BlockAttributes
99data BlockAttributes = BlockAttributes
100 { blockAttrName :: Maybe String
100 { blockAttrName :: Maybe String
101+ , blockAttrLabel :: Maybe String
101 , blockAttrCaption :: Maybe (F Inlines)
102 , blockAttrCaption :: Maybe (F Inlines)
102 , blockAttrKeyValues :: [(String, String)]
103 , blockAttrKeyValues :: [(String, String)]
@@ -117,12 +118,14 @@ blockAttributes = try $ do
117 let caption = foldl' (appendValues "CAPTION") Nothing kv
118 let caption = foldl' (appendValues "CAPTION") Nothing kv
118 let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv
119 let kvAttrs = foldl' (appendValues "ATTR_HTML") Nothing kv
119 let name = lookup "NAME" kv
120 let name = lookup "NAME" kv
121+ let label = lookup "LABEL" kv
120 caption' <- maybe (return Nothing)
122 caption' <- maybe (return Nothing)
121 (fmap Just . parseFromString inlines)
123 (fmap Just . parseFromString inlines)
123 kvAttrs' <- parseFromString keyValues . (++ "\n") $ fromMaybe mempty kvAttrs
125 kvAttrs' <- parseFromString keyValues . (++ "\n") $ fromMaybe mempty kvAttrs
124 return $ BlockAttributes
126 return $ BlockAttributes
125 { blockAttrName = name
127 { blockAttrName = name
128+ , blockAttrLabel = label
126 , blockAttrCaption = caption'
129 , blockAttrCaption = caption'
127 , blockAttrKeyValues = kvAttrs'
130 , blockAttrKeyValues = kvAttrs'
@@ -131,6 +134,7 @@ blockAttributes = try $ do
131 attrCheck attr =
134 attrCheck attr =
132 case attr of
135 case attr of
133 "NAME" -> True
136 "NAME" -> True
134 "CAPTION" -> True
138 "CAPTION" -> True
135 "ATTR_HTML" -> True
139 "ATTR_HTML" -> True
136 _ -> False
140 _ -> False
@@ -415,9 +419,10 @@ figure = try $ do
415 guard . not . isNothing . blockAttrCaption $ figAttrs
419 guard . not . isNothing . blockAttrCaption $ figAttrs
416 guard (isImageFilename src)
420 guard (isImageFilename src)
417 let figName = fromMaybe mempty $ blockAttrName figAttrs
421 let figName = fromMaybe mempty $ blockAttrName figAttrs
422+ let figLabel = fromMaybe mempty $ blockAttrLabel figAttrs
418 let figCaption = fromMaybe mempty $ blockAttrCaption figAttrs
423 let figCaption = fromMaybe mempty $ blockAttrCaption figAttrs
419 let figKeyVals = blockAttrKeyValues figAttrs
424 let figKeyVals = blockAttrKeyValues figAttrs
420− let attr = (mempty, mempty, figKeyVals)
425+ let attr = (figLabel, mempty, figKeyVals)
421 return $ (B.para . B.imageWith attr src (withFigPrefix figName) <$> figCaption)
426 return $ (B.para . B.imageWith attr src (withFigPrefix figName) <$> figCaption)
423 withFigPrefix :: String -> String
428 withFigPrefix :: String -> String