mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-05 12:57:33 +03:00
Update to latest markdown parser.
This commit is contained in:
parent
3d3588455d
commit
79f81ceac1
@ -161,7 +161,7 @@ type alias Renderer view =
|
|||||||
, italic : String -> view
|
, italic : String -> view
|
||||||
|
|
||||||
-- TODO make this a `Result` so users can validate links
|
-- TODO make this a `Result` so users can validate links
|
||||||
, link : { title : Maybe String, destination : String } -> String -> Result String view
|
, link : { title : Maybe String, destination : String } -> List view -> Result String view
|
||||||
, image : { src : String } -> String -> Result String view
|
, image : { src : String } -> String -> Result String view
|
||||||
, list : List view -> view
|
, list : List view -> view
|
||||||
, codeBlock : { body : String, language : Maybe String } -> view
|
, codeBlock : { body : String, language : Maybe String } -> view
|
||||||
@ -182,8 +182,19 @@ foldThing renderer { style, string } soFar =
|
|||||||
Just link ->
|
Just link ->
|
||||||
case link.destination of
|
case link.destination of
|
||||||
Inlines.Link destination ->
|
Inlines.Link destination ->
|
||||||
renderer.link { title = link.title, destination = destination } string
|
case Advanced.run Inlines.parse string of
|
||||||
:: soFar
|
Ok styledLine ->
|
||||||
|
(renderStyled renderer styledLine
|
||||||
|
|> Result.andThen
|
||||||
|
(\children ->
|
||||||
|
renderer.link { title = link.title, destination = destination } children
|
||||||
|
)
|
||||||
|
)
|
||||||
|
:: soFar
|
||||||
|
|
||||||
|
Err error ->
|
||||||
|
(error |> List.map deadEndToString |> List.map Err)
|
||||||
|
++ soFar
|
||||||
|
|
||||||
Inlines.Image src ->
|
Inlines.Image src ->
|
||||||
renderer.image { src = src } string
|
renderer.image { src = src } string
|
||||||
|
@ -76,6 +76,7 @@ view markdown =
|
|||||||
Err (error |> List.map Markdown.Parser.deadEndToString |> String.join "\n")
|
Err (error |> List.map Markdown.Parser.deadEndToString |> String.join "\n")
|
||||||
|
|
||||||
|
|
||||||
|
renderer : Markdown.Parser.Renderer (Element msg)
|
||||||
renderer =
|
renderer =
|
||||||
{ heading = heading
|
{ heading = heading
|
||||||
, raw =
|
, raw =
|
||||||
@ -92,9 +93,15 @@ renderer =
|
|||||||
|> Result.map
|
|> Result.map
|
||||||
(\() ->
|
(\() ->
|
||||||
Element.link
|
Element.link
|
||||||
[ Font.color Palette.color.primary
|
[ Element.htmlAttribute (Html.Attributes.style "display" "inline-flex")
|
||||||
]
|
]
|
||||||
{ url = link.destination, label = Element.text body }
|
{ url = link.destination
|
||||||
|
, label =
|
||||||
|
Element.paragraph
|
||||||
|
[ Font.color Palette.color.primary
|
||||||
|
]
|
||||||
|
body
|
||||||
|
}
|
||||||
)
|
)
|
||||||
, image =
|
, image =
|
||||||
\image body ->
|
\image body ->
|
||||||
@ -234,7 +241,6 @@ code snippet =
|
|||||||
(Element.rgba 0 0 0 0.04)
|
(Element.rgba 0 0 0 0.04)
|
||||||
, Element.Border.rounded 2
|
, Element.Border.rounded 2
|
||||||
, Element.paddingXY 5 3
|
, Element.paddingXY 5 3
|
||||||
, Font.color (Element.rgba255 0 0 0 1)
|
|
||||||
, Font.family [ Font.monospace ]
|
, Font.family [ Font.monospace ]
|
||||||
]
|
]
|
||||||
(Element.text snippet)
|
(Element.text snippet)
|
||||||
|
Loading…
Reference in New Issue
Block a user