Skip to content

Commit

Permalink
HTML reader: add size information for fa svg icons.
Browse files Browse the repository at this point in the history
If the icon has class fa-fw or fa-w16 or fa-w14, we add a width
attribute to prevent the icon from appearing full-width in PDF or
docx output.

Closes #10134.
  • Loading branch information
jgm committed Jan 7, 2025
1 parent 3511f16 commit 9933a41
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Text/Pandoc/Readers/HTML.hs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,10 @@ pSvg = do
let rawText = T.strip $ renderTags' (opent : contents ++ [closet])
let svgData = "data:image/svg+xml;base64," <>
UTF8.toText (encode $ UTF8.fromText rawText)
return $ B.imageWith (ident,cls,[]) svgData mempty mempty
let kvs = [("width", "1em") | "fa-w-14" `elem` cls ||
"fa-w-16" `elem` cls ||
"fa-fw" `elem` cls] -- #10134
return $ B.imageWith (ident,cls,kvs) svgData mempty mempty

pCodeWithClass :: PandocMonad m => Text -> Text -> TagParser m Inlines
pCodeWithClass name class' = try $ do
Expand Down

0 comments on commit 9933a41

Please sign in to comment.