# `MfmParser.Encoder`
[🔗](https://git.pleroma.social/pleroma-elixir-libraries/mfm-parser)

An encoder who can turn a String with MFM functions, or an MFM tree from `MfmParser.Parser.parse/1`, into FEP-c16b compliant HTML.

It only works for the MFM specific tags of the form `$[name.attributes content]`. Other parts of MFM (e.g. html, Markdown and [KaTeX](https://katex.org/)) are out of scope for this project.

## Examples

    iex> [
    ...>   %MfmParser.Node.MFM{
    ...>     name: "twitch",
    ...>     content: [%MfmParser.Node.Text{content: "🍮"}],
    ...>     attributes: [{"speed", "5s"}]
    ...>   }
    ...> ]
    ...> |> MfmParser.Encoder.to_html()
    ~S[<span class="mfm-twitch" data-mfm-speed="5s">🍮</span>]

    iex> "$[twitch.speed=5s 🍮]" |> MfmParser.Encoder.to_html()
    ~S[<span class="mfm-twitch" data-mfm-speed="5s">🍮</span>]

# `to_html`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
