Skip to content

Commit

Permalink
Merge pull request #7112 from quarto-dev/bugfix/6568
Browse files Browse the repository at this point in the history
if data-uri ends with default image extension, crop it.
  • Loading branch information
cscheid authored Oct 2, 2023
2 parents 19ab254 + b8e6775 commit 9e035c9
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/changelog-1.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@
- ([#6487](https://github.com/quarto-dev/quarto-cli/discussions/6487)): Fix `serviceworkers` check in `htmlDependency` to look at the correct key.
- ([#6178](https://github.com/quarto-dev/quarto-cli/pull/6178)): When `QUARTO_LOG_LEVEL=DEBUG`, information about search for a R binary will be shown.
- ([#5755](https://github.com/quarto-dev/quarto-cli/pull/5755)): Allow document metadata to control conditional content.
- ([#6568](https://github.com/quarto-dev/quarto-cli/issues/6568)): Trim file extension in data URI that might have been inadvertently added by Pandoc.
- ([#6620](https://github.com/quarto-dev/quarto-cli/pull/6620)): Rewrite Crossreferenceable figure support. See the [prerelease documentation](https://quarto.org/docs/prerelease/1.4/) for more information.
- ([#6697](https://github.com/quarto-dev/quarto-cli/pull/6697)): Fix issue with outputing to stdout (`quarto render <file> -o -`) on Windows.
- ([#6705](https://github.com/quarto-dev/quarto-cli/pull/6705)): Fix issue with gfm output being removed when rendered with other formats.
Expand Down
3 changes: 3 additions & 0 deletions src/resources/filters/crossref/crossref.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ import("../normalize/flags.lua")
import("../normalize/normalize.lua")
import("../normalize/parsehtml.lua")
import("../normalize/extractquartodom.lua")
import("../normalize/astpipeline.lua")
import("../normalize/capturereaderstate.lua")
import("../normalize/fixupdatauri.lua")

import("../crossref/custom.lua")
import("../crossref/index.lua")
Expand Down
1 change: 1 addition & 0 deletions src/resources/filters/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import("./normalize/parsehtml.lua")
import("./normalize/extractquartodom.lua")
import("./normalize/astpipeline.lua")
import("./normalize/capturereaderstate.lua")
import("./normalize/fixupdatauri.lua")

import("./layout/meta.lua")
import("./layout/width.lua")
Expand Down
1 change: 1 addition & 0 deletions src/resources/filters/normalize/astpipeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function quarto_ast_pipeline()
parse_html_tables(),
parse_extended_nodes(),
code_filename(),
normalize_fixup_data_uri_image_extension(),
})
},
{
Expand Down
18 changes: 18 additions & 0 deletions src/resources/filters/normalize/fixupdatauri.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- fixupdatauri.lua
-- Copyright (C) 2023 Posit Software, PBC

-- https://github.com/quarto-dev/quarto-cli/issues/6568
function normalize_fixup_data_uri_image_extension()
return {
Image = function(img)
local src = img.src
if src:sub(1, 5) == "data:" then
local l = PANDOC_READER_OPTIONS.default_image_extension:len()
if src:sub(-l-1) == ("." .. PANDOC_READER_OPTIONS.default_image_extension) then
img.src = src:sub(1, -l - 2)
return img
end
end
end
}
end
16 changes: 16 additions & 0 deletions tests/docs/smoke-all/2023/10/02/6568.qmd

Large diffs are not rendered by default.

0 comments on commit 9e035c9

Please sign in to comment.