Closed cllns closed 1 year ago
Hey! Thank you for reporting the issue and finding the relevant code.
trimmed : String
trimmed =
String.trim textBody
|> Regex.replace
(Regex.fromString "\\s+"
|> Maybe.withDefault Regex.never
)
(\_ -> " ")
This is the current implementation (as you linked to). I wonder if the regex replace is sufficient and maybe just removing the String.trim
would handle it correctly?
Okay, I think this might address the issues. Here's a preview of the deployed site that you can play around with, any thoughts?
https://deploy-preview-20--html-to-elm-tailwind.netlify.app/
The one case that comes to mind that I'm not sure about is if whitespace needs to be preserved within nodes that have nothing but whitespace or if it is safe to remove all whitespace within whitespace-only nodes. Otherwise it's seeming pretty good.
Thanks @dillonkearns. Sorry I didn't look at it in a timely manner but the preview link looks great
No problem, thanks for taking a look! It's live now on the site and new package release. Thanks again for reporting the issue! 🙏
Amazing and helpful tool!
I ran into a small issue when copying HTML from TailwindUI into elm-to-html.com
The issue is that
text
nodes are run throughString.trim
. This makes for cleaner strings, but whitespace has semantic meaning in text nodes, which is lost.(I could see 'fixing' this possibly generating very long trailing spaces and new lines, so maybe any whitespace could be collapsed into a single space? Not sure if that's actually tenable.)
Here is the original/expected HTML, followed by the HTML generated by Elm, after having been passed through elm-to-html.com
Expected:
Actual: