Skip to content

Commit 3f97e3d

Browse files
committed
Overwrite Markdown links to use UnisonShare.Link
1 parent 8a1169e commit 3f97e3d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/UnisonShare/Markdown.elm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
module 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)
44
import Html.Attributes exposing (class)
55
import Markdown.Parser as MdParser
66
import Markdown.Renderer exposing (defaultHtmlRenderer)
7+
import UnisonShare.Link as Link
78

89

910
viewCodeBlock : { 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+
2029
view_ : List (Attribute msg) -> String -> Html msg
2130
view_ 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

Comments
 (0)