douceur
douceur copied to clipboard
nbsp is replaced with space
The inliner library replaces
is replaced with a space character. In my opinion, inliner should leave
as it is. Here is a short test.
html := `
<html>
<head>
<style type="text/css">
body {
background-color: #f2f2f2;
}
</style>
</head>
<body>
<p> </p>
</body>
</html>`
inline, _ := inliner.Inline(html)
fmt.Println(inline)
This prints:
<html><head>
</head>
<body style="background-color: #f2f2f2;" bgcolor="#f2f2f2">
<p> </p>
</body></html>
Any quick fix for this?
it happens with
©
too
Stuck into the same problem, after some hours searching came up with a solution.
The problem is: the inliner library parses html using the standard library into tree, replacing all special html symbols with unicode ones (e.g. " " is replaced by "\u00a0"). So when you do
fmt.Println(inline)
the non-breaking space will be printed as an ordinary space.
I found an example solution there: https://gist.github.com/brandonrachal/10605780
Minimal playground test likely gives us the expected result: https://play.golang.org/p/rgYqA7x7jL3
Hope it'll help!