This function wraps html in SVG group tags (i.e. <g>). This may then be wrapped in <svg> tags to create a stand-along SVG.

as_svg_group(
  x,
  width = 1200,
  height = 900,
  font_size = NULL,
  style = list(),
  visible = TRUE,
  extra = NULL,
  ...
)

Arguments

x

emphatic object

width, height

viewBox dimensions for SVG

font_size

CSS font-size. Default: NULL means to not adjust font size. Otherwise, use valid CSS font-size specification e.g. "3em", "22px" etc.

style

html tag styling to apply to the <pre> wrapper for the returned HTML

visible

should the group be visible? Default: TRUE. When animating, every frame other than the first should be set as visible = FALSE.

extra

extra tags to insert into group. default NULL

...

other arguments passed to as.character.emphatic()

Value

Character string containing representation as an SVG group element i.e. <g>. This result is suitable for combining with other SVG elements into a custom SVG document.

Details

This function is used internall by both as_svg() and as_svg_anim()

Examples

hl_diff('hello', 'there') |>
  as_svg_group() |>
  cat()
#> <g visibility="visible">
#> <foreignObject width="100%" height="100%">
#> <div xmlns="http://www.w3.org/1999/xhtml">
#> <pre style=''>
#> <span><span>[1] &quot;</span></span><span style='color:#000000;'><span style='background-color:#9aff9a;'> </span></span><span><span>he</span></span><span style='color:#000000;'><span style='background-color:#97ffff;'>ll</span></span><span style='color:#000000;'><span style='background-color:#ff7f50;'>o</span></span><span><span>&quot;</span></span><br/><span><span>[1] &quot;</span></span><span style='color:#000000;'><span style='background-color:#9aff9a;'>t</span></span><span><span>he</span></span><span style='color:#000000;'><span style='background-color:#97ffff;'>re</span></span><span style='color:#000000;'><span style='background-color:#ff7f50;'> </span></span><span><span>&quot;</span></span>
#> </pre>
#> </div>
#> </foreignObject>
#> 
#> </g>