Skip to content

Commit

Permalink
Example of Listener changing state
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Matiushkin committed Jul 1, 2023
1 parent baec3b1 commit ddcb17f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/md/listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,17 @@ defmodule Md.Listener.Debug do
@moduledoc false
use Md.Listener
end

defmodule Md.Listener.Beautifier do
@moduledoc false
use Md.Listener

alias Md.Parser.State

def handle_tag({:p, false}, %State{ast: [{:p, attrs, [title]}]} = state)
when byte_size(title) < 42 do
{:update, %State{state | ast: [{:h1, attrs, [title]}]}}
end

def handle_tag(_, _), do: :ok
end

0 comments on commit ddcb17f

Please sign in to comment.