mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-11-05 08:34:38 +03:00
Remove extra markdown paragraph padding from balloons
This commit is contained in:
parent
73ea410205
commit
a8d65c58a2
@ -6,6 +6,8 @@ import Css
|
||||
import Html.Styled exposing (..)
|
||||
import Html.Styled.Attributes exposing (css)
|
||||
import Markdown
|
||||
import Markdown.Block
|
||||
import Markdown.Inline
|
||||
|
||||
|
||||
{-| Provide a plain-text string.
|
||||
@ -51,6 +53,22 @@ markdownContent content =
|
||||
|> List.map fromUnstyled
|
||||
|
||||
|
||||
{-| Provide a string that will be rendered as markdown and placed in a paragraph tag, with the default margin removed.
|
||||
-}
|
||||
markdownParagraph : String -> List (Html msg)
|
||||
markdownParagraph content =
|
||||
case Markdown.Block.parse Nothing content of
|
||||
[ Markdown.Block.Paragraph _ inlines ] ->
|
||||
-- The library always parses into a paragraph and never into `PlainInline`
|
||||
List.map (Markdown.Inline.toHtml >> fromUnstyled) inlines
|
||||
|> p [ css [ Css.margin Css.zero ] ]
|
||||
|> List.singleton
|
||||
|
||||
_ ->
|
||||
Markdown.toHtml Nothing content
|
||||
|> List.map fromUnstyled
|
||||
|
||||
|
||||
{-| Provide a list of custom HTML.
|
||||
-}
|
||||
html :
|
||||
|
@ -376,7 +376,7 @@ markdown content =
|
||||
Attribute <|
|
||||
\config ->
|
||||
{ config
|
||||
| content = Content.markdownContent content
|
||||
| content = Content.markdownParagraph content
|
||||
, css = MarkdownStyles.anchorAndButton ++ config.css
|
||||
}
|
||||
|
||||
|
@ -262,16 +262,6 @@ view_ tagStyle viewSegment highlightables =
|
||||
segments
|
||||
|
||||
|
||||
stripMarkdownSyntax : String -> String
|
||||
stripMarkdownSyntax markdown =
|
||||
case Markdown.Block.parse Nothing markdown of
|
||||
[ Markdown.Block.Paragraph _ inlines ] ->
|
||||
Markdown.Inline.extractText inlines
|
||||
|
||||
_ ->
|
||||
markdown
|
||||
|
||||
|
||||
viewMarkedByBalloon :
|
||||
{ config
|
||||
| backgroundColor : Color
|
||||
@ -598,3 +588,13 @@ viewBalloonSpacer config =
|
||||
]
|
||||
[ Html.text "()" ]
|
||||
]
|
||||
|
||||
|
||||
stripMarkdownSyntax : String -> String
|
||||
stripMarkdownSyntax markdown =
|
||||
case Markdown.Block.parse Nothing markdown of
|
||||
[ Markdown.Block.Paragraph _ inlines ] ->
|
||||
Markdown.Inline.extractText inlines
|
||||
|
||||
_ ->
|
||||
markdown
|
||||
|
Loading…
Reference in New Issue
Block a user