Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shouldn't *.../.../...* be nested? #34

Open
liwoxa opened this issue Oct 2, 2019 · 0 comments
Open

Shouldn't *.../.../...* be nested? #34

liwoxa opened this issue Oct 2, 2019 · 0 comments

Comments

@liwoxa
Copy link

liwoxa commented Oct 2, 2019

I want to do X

I wish

A *strongly emphasized bit with an inner /additionally/ emphasized bit*.

could be rendered as (1)

A <strong>strongly emphasized bit with an inner <em>additionally</em> emphasized bit</strong>.

but the design seems to prohibit this, only allowing something like (2)

A <strong>strongly emphasized bit with an inner </strong><strong><em>additionally</em></strong><strong> emphasized bit</strong>.

If only I could do Y

If the package would expose something like

type Nestable
  = Strong
  | Em
  | Del

Mark.textNestable : (Nestable -> text -> text) -> Block (List text)
--                              ------
--                     not sure about this part of the type

then instead of something like (1)

styledText styles string =
    if styles.bold then
        if styles.italic then
            Html.strong [] [ Html.em [] [ Html.text string ] ]
        else
            Html.strong [] [ Html.text string ]
    else
        if styles.italic then
            Html.em [] [ Html.text string ]
        else
            Html.text string
-- For brevity I ignored `styles.strike`

textify = Mark.text styledText

I could write (2)

nestedText nest content =
    case nest of
        Bold ->
            Html.strong [] content
        Em ->
            Html.em [] content
        Del ->
            Html.del [] content

textify = Mark.textNestable nestedText
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant