I wrote an live editor for HTML. My app has an input field for the html code and a text field that shows the rendered output. For rendering the code input, I used this package: https://package.elm-lang.org/packages/hecrj/html-parser/. Is there a way to also parse CSS code an change the output accordingly.
I don’t think there’s a parser for CSS in Elm yet, but you can just put the CSS string in a style tag in your view function to “run” it: Html.node "style" [] [Html.text myCssString]
I have some other difficulties with the project. I wanted to have two modes one for only editing HTML and another for HTML and CSS.
You can see the HTML Mode here:
I tired a few values and found the right ones for my browser and my monitor, so
that that editor and the box for the result have the same height and the user doesn’t need to scroll. On every other element I used fill or shrink.
My Problem is that it doesn’t look good in other Browsers or on another Monitor.
Whats the right way to use no hard-coding and make it look good on every device.
Have you considered using a Web Component to render the HTML and CSS? That might be a simpler and more robust way to do that that avoids having to manually do HTML or CSS parsing.