Renders an icon's SVG markup to a base64-encoded URI.

This enables self-contained and styled icon for consumers that use image paths/URLs, including for example: an <img src>, a gt::html() cell, and a leaflet marker iconUrl.

icon_uri(x)

Arguments

x

An icons vector.

Value

A character vector giving each icon's base64 encoded URI.

Examples

path <- tempfile(fileext = ".svg")
writeLines(
  '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M0 0"/></svg>',
  path
)
icon_uri(read_icon(path))
#>                                                                                                                                                                                                         /tmp/RtmpLcI8AJ/file1a943e9fa4bc.svg 
#> "data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIHN0eWxlPSJoZWlnaHQ6MWVtO2Rpc3BsYXk6aW5saW5lLWJsb2NrO3ZlcnRpY2FsLWFsaWduOi0uMWVtOyIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8cGF0aCBkPSJNMCAwIj48L3BhdGg+Cjwvc3ZnPg=="