Serum icon indicating copy to clipboard operation
Serum copied to clipboard

Escape & in anchors

Open igalic opened this issue 4 years ago • 8 comments

In "manually" tidying the generated HTML, i stumbled upon the following issues reported by tidy:

line 36 column 205 - Warning: unescaped & or unknown entity "&-voxpupuli"
line 37 column 1011 - Warning: unescaped & or unknown entity "&-s-it"

this tells me that we need to escape, or skip & when using it in anchors.

igalic avatar May 09 '20 14:05 igalic

Thank you for your report! Where did you find those strings? In id attribute of HTML tags? For example:

<h2 id="&-voxpupuli" ...>...</h2>

Dalgona avatar May 09 '20 14:05 Dalgona

Thank you for your report! Where did you find those strings? In id attribute of HTML tags? For example:

yup, although it looked more like:

<h2 id="puppet-&-voxpupuli" ...>...</h2>

funnily enough, this happens whether my markdown says:

## Puppet & Voxpupuli

or

## Puppet &amp; Voxpupuli

igalic avatar May 09 '20 15:05 igalic

Yes, that's becuase of how Serum generates element IDs based on text contents of <h*> tags. I'll find out how to properly normalize those ID values.

Dalgona avatar May 09 '20 15:05 Dalgona

One thing to ask, what version of Serum are you using? I cannot reproduce this problem on my side. If you are using an old version, please update it and try again. (Better escaping of anchors will be implemented anyway, though.)

Dalgona avatar May 10 '20 12:05 Dalgona


  defp deps do
    [
      {:serum, git: "https://github.com/Dalgona/Serum.git", branch: "master"},
    ]
  end

igalic avatar May 10 '20 18:05 igalic

I see, you were on a bleeding edge! To make sure you're using the latest commit of Serum v1, Please try updating your deps to...

defp deps do
  [
    {:serum, git: "https://github.com/Dalgona/Serum.git", branch: "v1/master"},
    # ...
  ]
end

Clean (or delete) your deps directory, fetch your dependency again using mix deps.get, and see if the problem still persists.

Dalgona avatar May 10 '20 23:05 Dalgona

Your website is now ready!
Copy(or move) the contents of `site` directory
into your public webpages directory.
tidy -config tidy.config site/*.html || true

looking good.

igalic avatar May 12 '20 18:05 igalic

Glad to hear that.

I'm leaving this thread open since there are some other quirks related to encoding HTML entities.

Dalgona avatar May 12 '20 22:05 Dalgona