diff --git a/lib/encoder.ex b/lib/encoder.ex index a8e7be2..43fe995 100644 --- a/lib/encoder.ex +++ b/lib/encoder.ex @@ -76,9 +76,10 @@ defmodule MfmParser.Encoder do %Node.MFM.X{} -> html_child = to_html_styles(node.children) + prop_map = %{"200%" => "2", "400%" => "3", "600%" => "4"} temple do - span style: "font-size: #{node.props.size}" do + span style: "font-size: #{node.props.size}", class: "mfm _mfm_x#{prop_map[node.props.size]}_" do html_child end end @@ -93,13 +94,13 @@ defmodule MfmParser.Encoder do %Node.MFM.Jelly{} -> html_child = to_html_styles(node.children) - "#{html_child}" + "#{html_child}" %Node.MFM.Tada{} -> html_child = to_html_styles(node.children) temple do - span class: "mfm", + span class: "mfm _mfm_tada_", style: "display: inline-block; font-size: 150%; animation: #{node.props.speed} linear 0s infinite normal both running mfm-tada;" do html_child @@ -109,12 +110,12 @@ defmodule MfmParser.Encoder do %Node.MFM.Jump{} -> html_child = to_html_styles(node.children) - "#{html_child}" + "#{html_child}" %Node.MFM.Bounce{} -> html_child = to_html_styles(node.children) - "#{html_child}" + "#{html_child}" %Node.MFM.Spin{} -> html_child = to_html_styles(node.children) @@ -129,7 +130,7 @@ defmodule MfmParser.Encoder do "left" => "reverse" } - "#{html_child}" + "#{html_child}" %Node.MFM.Shake{} -> html_child = to_html_styles(node.children) diff --git a/test/encoder_test.exs b/test/encoder_test.exs index 7623f56..974b107 100644 --- a/test/encoder_test.exs +++ b/test/encoder_test.exs @@ -80,7 +80,7 @@ defmodule MfmParser.EncoderTest do } ] - expected = ~s[🍮] + expected = ~s[🍮] assert Encoder.to_html(input_tree) == expected end @@ -105,7 +105,7 @@ defmodule MfmParser.EncoderTest do ] expected = - ~s[🍮] + ~s[🍮] assert Encoder.to_html(input_tree) == expected end @@ -118,7 +118,7 @@ defmodule MfmParser.EncoderTest do ] expected = - ~s[🍮] + ~s[🍮] assert Encoder.to_html(input_tree) == expected end @@ -131,7 +131,7 @@ defmodule MfmParser.EncoderTest do ] expected = - ~s[🍮] + ~s[🍮] assert Encoder.to_html(input_tree) == expected end @@ -144,7 +144,7 @@ defmodule MfmParser.EncoderTest do ] expected = - ~s[🍮] + ~s[🍮] assert Encoder.to_html(input_tree) == expected end @@ -214,31 +214,31 @@ defmodule MfmParser.EncoderTest do ] expected_tree_z_left = - ~s[🍮] + ~s[🍮] expected_tree_x_left = - ~s[🍮] + ~s[🍮] expected_tree_y_left = - ~s[🍮] + ~s[🍮] expected_tree_z_alternate = - ~s[🍮] + ~s[🍮] expected_tree_x_alternate = - ~s[🍮] + ~s[🍮] expected_tree_y_alternate = - ~s[🍮] + ~s[🍮] expected_tree_z_normal = - ~s[🍮] + ~s[🍮] expected_tree_x_normal = - ~s[🍮] + ~s[🍮] expected_tree_y_normal = - ~s[🍮] + ~s[🍮] assert Encoder.to_html(input_tree_z_left) == expected_tree_z_left assert Encoder.to_html(input_tree_x_left) == expected_tree_x_left @@ -414,7 +414,7 @@ defmodule MfmParser.EncoderTest do ] expected = - "It's not chocolatine\nit's pain au chocolat" + "It's not chocolatine\nit's pain au chocolat" assert Encoder.to_html(input_tree) == expected end @@ -424,7 +424,7 @@ defmodule MfmParser.EncoderTest do "It's not $[twitch.speed=0.2s chocolatine]\nit's $[x4 $[spin.speed=1s pain] $[rainbow.speed=2s au] $[jump.speed=0.5s chocolat]]" expected = - "It's not chocolatine\nit's pain au chocolat" + "It's not chocolatine\nit's pain au chocolat" assert Encoder.to_html(input) == expected end