processing / p5.js-website

New p5.js website!
http://p5js.org
MIT License
18 stars 90 forks source link

fix: Skip escaping if already escaped in the code tag. #606

Closed shibomb closed 1 month ago

shibomb commented 1 month ago

Resolves #587

This is a proposal. It seems to work well on the following page in my local env. /reference/p5/createInput/ /reference/p5/Boolean/ /reference/p5/Number/

changes:

Check if the content is already escaped by looking for common HTML entities in code tag. If already escaped, skip escaping.

davepagurek commented 1 month ago

This is a good fix for right now while we have stuff written in an inconsistent format. We should also address that at the source (details in https://github.com/processing/p5.js-website/issues/587#issuecomment-2422407707) but this will help us not have broken content in the mean time!

davepagurek commented 1 month ago

One note is that it means we can't easily write code in p5 explaining how HTML escaping works because if we try to explicitly write &lt; as I've done here, it would render as < in our docs. I think that's fine since we probably don't need to do that in p5, but once the source is addressed, the plan will be to remove this check again.