zwilias / elm-html-string

Drop in elm-lang/html replacement which can serialize to a pretty `String`
http://package.elm-lang.org/packages/zwilias/elm-html-string/latest
BSD 3-Clause "New" or "Revised" License
25 stars 9 forks source link

Cooperation with elm-css #8

Open gitLabor8 opened 4 years ago

gitLabor8 commented 4 years ago

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.

zwilias commented 4 years ago

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:

(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.

gitLabor8 commented 4 years ago

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!