From 16afffa4a11f80c55fc191fd46f00814cb85453e Mon Sep 17 00:00:00 2001 From: Yihui Xie Date: Sun, 5 Jan 2025 15:55:45 -0600 Subject: [PATCH] inline SVG images instead of base64 encoding them, to make it possible to manipulate/style them via JS/CSS, and the file size will also be smaller (base64 encoding increases the file size by 1/3) --- DESCRIPTION | 2 +- NEWS.md | 2 ++ R/utils.R | 43 +++++++++++++++++++++++++-------- docs/04-mark.Rmd | 59 ++++++++++++++++++++++++++++------------------ docs/05-assets.Rmd | 38 ++++++++++++++++------------- 5 files changed, 94 insertions(+), 50 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 0fa3bef..2826796 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: litedown Type: Package Title: A Lightweight Version of R Markdown -Version: 0.4.13 +Version: 0.4.14 Authors@R: c( person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666", URL = "https://yihui.org")), person("Tim", "Taylor", role = "ctb", comment = c(ORCID = "0000-0002-8587-7113")), diff --git a/NEWS.md b/NEWS.md index f98bf8d..11a19f0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,8 @@ - Added options `dollar`, `signif`, and `power` to format numbers from inline code. See https://yihui.org/litedown/#sec:inline-code for details. +- When embedding SVG images in HTML output, embed their raw XML content instead of base64 encoding them. + - Empty table headers are removed in HTML output (they may be generated from data frames or matrices without column names). - Added support for the chunk option `collapse = TRUE` (thanks, @J-Moravec, #40). diff --git a/R/utils.R b/R/utils.R index 9e80131..563810b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -949,23 +949,33 @@ embed_resources = function(x, options) { if (!any(embed)) return(x) clean = isTRUE(options[['embed_cleanup']]) - r = '(]* src="|