elm-html-string icon indicating copy to clipboard operation
elm-html-string copied to clipboard

Cooperation with elm-css

Open gitLabor8 opened this issue 5 years ago • 2 comments

Hello,

I have an established Elm project that uses RtFeldman's elm-css to add type safety in my CSS. Now I want to export this Html as pdf.

For this I want to use elm-html-string. I can convert my current structure in elm-css' Html to elm-core's Html. However, by that point I can't get it to work with this library anymore, as there is no fromHtml (probably with good reason).

Is there any way for me to keep the CSS-type safety that elm-css gives me and also render the Html as a regular Html string?

Thanks in advance.

gitLabor8 avatar Apr 29 '20 12:04 gitLabor8

I fear that the way projects like elm/html, elm-css and this very package are set up makes this quite hard: all three projects use opaque types to keep internal details internal. Both this package and elm-css then provide a way to convert that internal type to an elm/html representation, but there is no way to extract structure from elm/html, so that's a one way street.

I see only two ways for this to work:

  • elm-css adds a way to return elm-html-string elements
  • elm-html-string duplicates the entire elm-css API

(or, as a third alternative, both libraries could build on a common, open abstraction that would allow rendering "down" to some final format, somehow 🤔)

I will do some investigation on this, but I don't think there will be a solution in the very short term.

zwilias avatar Apr 30 '20 09:04 zwilias

Sorry to hear that. I get where you're coming from. The third option seems the neatest, as it allows other libraries to join in later on. However, it's also by far the slowest and most labourful.

Good luck with your investigation!

gitLabor8 avatar Apr 30 '20 15:04 gitLabor8