Users often don't realize that they are dealing with grid graphics, e.g., because they might have simply used a plot method from some package. This can lead to code like this which throws an uninformative error:
library(grid)
library(rvg)
library(officer)
p <- grid.rect(gp = gpar(fill = "red"), draw = FALSE)
read_pptx() |>
add_slide(layout = "Title and Content", master = "Office Theme") |>
ph_with(dml(code = {
p
}),
location = ph_location_type(type = "body"))
#Error in read_xml.raw(charToRaw(enc2utf8(x)), "UTF-8", ..., as_html = as_html, :
# StartTag: invalid element name [68]
It would be nice if the error message could give users a hint that they might have a grid graphics object and should try plot(p). Even better if ph_with.dml could automagically do that for the user.
This came up on Stackoverflow: https://stackoverflow.com/q/78865088/1412059
Users often don't realize that they are dealing with grid graphics, e.g., because they might have simply used a
plot
method from some package. This can lead to code like this which throws an uninformative error:It would be nice if the error message could give users a hint that they might have a grid graphics object and should try
plot(p)
. Even better ifph_with.dml
could automagically do that for the user.