Body:
When using element_markdown() or element_textbox_simple() in ggtext, an tag whose content begins with a straight double-quote character (", U+0022) fails to apply italic formatting and introduces unexpected whitespace before the first word after the quote.
Minimal reprex:
library(ggplot2)
library(ggtext)
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
labs(subtitle = '"In reaching for an oxygen cylinder, a climber degrades Everest."') +
theme(plot.subtitle = element_markdown())
Expected: The entire quoted sentence rendered in italics, with normal spacing.
Observed: "In" is not italicized; a phantom space appears between "In" and "reaching".
Workaround: Remove the leading " so that opens directly onto a plain letter:
subtitle = 'In reaching for an oxygen cylinder, a climber degrades Everest.'
This renders correctly, but requires dropping the quotation mark, which is not always acceptable.
Suspected cause: The HTML/XML parser appears to misinterpret " immediately following > — possibly treating it as an attribute-value delimiter — which breaks the italic context and produces spurious whitespace.
Environment: ggtext 0.1.2, gridtext 0.1.5, R 4.6.0, macOS.
Body:
When using element_markdown() or element_textbox_simple() in ggtext, an tag whose content begins with a straight double-quote character (", U+0022) fails to apply italic formatting and introduces unexpected whitespace before the first word after the quote.
Minimal reprex:
library(ggplot2)
library(ggtext)
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
labs(subtitle = '"In reaching for an oxygen cylinder, a climber degrades Everest."') +
theme(plot.subtitle = element_markdown())
Expected: The entire quoted sentence rendered in italics, with normal spacing.
Observed: "In" is not italicized; a phantom space appears between "In" and "reaching".
Workaround: Remove the leading " so that opens directly onto a plain letter:
subtitle = 'In reaching for an oxygen cylinder, a climber degrades Everest.'
This renders correctly, but requires dropping the quotation mark, which is not always acceptable.
Suspected cause: The HTML/XML parser appears to misinterpret " immediately following > — possibly treating it as an attribute-value delimiter — which breaks the italic context and produces spurious whitespace.
Environment: ggtext 0.1.2, gridtext 0.1.5, R 4.6.0, macOS.