Files
phosphoricons/lib/mix/heroicons/svg_processor.ex
2022-08-31 17:23:23 -04:00

21 lines
659 B
Elixir

defmodule Mix.Heroicons.SvgProcessor do
alias Mix.Heroicons.SvgProcessor.Handler
@moduledoc """
An SVG parser loosly based on https://github.com/svg/svgo
## Options
Currently supports the following options:
* `:remove_dimensions` - remove the `width` and `height` attributes. Defaults to false.
* `:sort_attributes` - sort the svg attributes by name. Default to false.
* `:remove_attributes` - list of attributes to remove
* `:add_attributes` - list of `{"name", "value"}` pairs of attributes to add
"""
def process(svg, opts \\ []) do
{:ok, stack} = Saxy.parse_string(svg, Handler, {[], opts})
Saxy.encode!(stack)
end
end