Created
April 22, 2017 05:52
-
-
Save glinesbdev/9f6dfa995ac5c95a26554209bdc4b44e to your computer and use it in GitHub Desktop.
Text to Html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Main exposing (..) | |
| import Html exposing (Html, text, img, div) | |
| import Html.Attributes exposing (src) | |
| sampleText : String | |
| sampleText = | |
| "Once during your turn (before you attack), you may turn all basic Energy attached to all of your Pokémon into Fire Energy for the rest of the turn. This power can't be used if Charizard is affected by a Special Condition." | |
| splitText : String -> List String | |
| splitText string = | |
| String.words string | |
| replaceText : List String -> Html a | |
| replaceText words = | |
| let | |
| url = | |
| "https://s3-us-west-2.amazonaws.com/pokecard/assets/icons/elements/Fire-icon.png" | |
| in | |
| List.map (\word -> | |
| case word of | |
| "Fire" -> | |
| img [ src url ] [] | |
| _ as val -> | |
| " " ++ val ++ " " | |
| |> text | |
| ) words | |
| |> div [] | |
| main : Html a | |
| main = | |
| sampleText |> splitText |> replaceText |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment