Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nbsp is replaced with space #5

Open
shardnit opened this issue Jul 12, 2016 · 2 comments
Open

nbsp is replaced with space #5

shardnit opened this issue Jul 12, 2016 · 2 comments

Comments

@shardnit
Copy link

shardnit commented Jul 12, 2016

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>&nbsp;</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?

@rraymondseek
Copy link

rraymondseek commented Nov 7, 2016

it happens with

&copy;

too

@nexterot
Copy link

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. "&nbsp;" 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants