Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to ignore unimplemented tags instead of throwing an error #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ktrask
Copy link

@ktrask ktrask commented May 16, 2023

I encountered a the error message Error: gridtext has encountered a tag that isn't supported yet: <code> while not adding this <code> tag anywhere. It came because sometimes ggplot adds backticks in some cases in axis labels. And the backticks are evaluated by the markdown package to <code>-tags.
Also I cannot control all the labels that are used in the software I want to use gridtext/ggtext in, I wanted the option to prevent gridtext to stop on unknown tags. So I added it.

Example:

library(grid)
library(gridtext)
options(gridtext.stop_if_tag_is_unimplemented=FALSE)
g <- textbox_grob(
  "Test `backticks`",
  x = unit(0.5, "npc"), y = unit(0.7, "npc"),
  gp = gpar(fontsize = 15),
  box_gp = gpar(col = "black", fill = "lightcyan1"),
  r = unit(5, "pt"),
  padding = unit(c(10, 10, 10, 10), "pt"),
  margin = unit(c(0, 10, 0, 10), "pt")
)
grid.newpage()
grid.draw(g)

@clauswilke
Copy link
Collaborator

That seems a bit over-engineered. I think it's fine to just replace the error with a warning. The main reason why I put the error there was I didn't want hundreds of bug reports that certain things don't render correctly when there was never any support of those features to begin with. But a warning communicates that just the same. (In my experience from teaching R to hundreds of undergrads, they typically think a warning is an error anyways.)

@ktrask
Copy link
Author

ktrask commented May 17, 2023

Thank you for the feedback!

I have changed the code accordingly and just changed the error to a warning about unimplemented tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants