11module UnisonShare.Markdown exposing (view , view_ )
22
3- import Html exposing (Attribute , Html , code , div , pre , text )
3+ import Html exposing (Attribute , Html , code , div , pre , span , text )
44import Html.Attributes exposing (class )
55import Markdown.Parser as MdParser
66import Markdown.Renderer exposing (defaultHtmlRenderer )
7+ import UnisonShare.Link as Link
78
89
910viewCodeBlock : { body : String , language : Maybe String } -> Html msg
@@ -17,6 +18,14 @@ viewCodeBlock { body, language } =
1718 pre ( class " source code" :: langAttr) [ code [] [ text body ] ]
1819
1920
21+ {- | TODO: UnisonShare.Link (UI.Click really) should support "title"
22+ -}
23+ viewLink : { title : Maybe String , destination : String } -> List (Html msg ) -> Html msg
24+ viewLink { destination } content =
25+ Link . link destination
26+ |> Link . view_ ( span [] content)
27+
28+
2029view_ : List (Attribute msg ) -> String -> Html msg
2130view_ attrs rawMarkdown =
2231 let
@@ -26,7 +35,7 @@ view_ attrs rawMarkdown =
2635 |> String . join " \n "
2736
2837 renderer =
29- { defaultHtmlRenderer | codeBlock = viewCodeBlock }
38+ { defaultHtmlRenderer | link = viewLink , codeBlock = viewCodeBlock }
3039
3140 content =
3241 case
0 commit comments