this post was submitted on 30 Jul 2023
130 points (90.6% liked)

Technology

59300 readers
5014 users here now

This is a most excellent place for technology news and articles.


Our Rules


  1. Follow the lemmy.world rules.
  2. Only tech related content.
  3. Be excellent to each another!
  4. Mod approved content bots can post up to 10 articles per day.
  5. Threads asking for personal tech support may be deleted.
  6. Politics threads may be removed.
  7. No memes allowed as posts, OK to post as comments.
  8. Only approved bots from the list below, to ask if your bot can be added please contact us.
  9. Check for duplicates before posting, duplicates may be removed

Approved Bots


founded 1 year ago
MODERATORS
 

Dear sweet Oghma. We can't even get rid of it on TTRPGs.

you are viewing a single comment's thread
view the rest of the comments
[–] AlexisFR@jlai.lu 4 points 1 year ago (2 children)

Why do posters keep writing &Amp instead of just &?

[–] nous@programming.dev 6 points 1 year ago* (last edited 1 year ago) (1 children)

EDIT: seems it wont render ampersand correctly at all.. so the below is just has everything escaped when I didn't mean it to be and more confusing than it should be because of this... not sure how to get ampersand to display correctly in a code block, seems to be bugged.

& is the HTML escape code for ~~&~~ ampersand. As ~~&~~ ampersand is a special character in HTML which means entity reference and should you can use the escaped form to get the browser to render just & rather than treating it as a reference. The same goes for other characters like ~~<~~ less than or > etc. However a lot of browsers still treat ~~&~~ ampersand as a literal in places where it does not look like a reference so the literal still works in a lot of places. But the escaped form always works.

But when you copy html from a page your browser is probably copying the escaped form the page used in its source rather then the rendered form. It does this to let you get rich markup when pasting into documents - the app you paste into understands the html and knows when you are using heading or bolding text etc.

But in this case the app just pasted in the escaped form with no conversation. And for security reasons likely escaped it again as you don't want users to be able to post any old html formatting in a comment, so any html special characters in the input get escaped leaving you with a double escaped char, which the browser only unescapes one layer of when rendering.

[–] nous@programming.dev 5 points 1 year ago* (last edited 1 year ago)

Heh, well, look at that... seems it is also escaping chars inside backticks, but then not undoing that on the render when it conveys them to a pre tag... Which IMO seems like a bug in lemmy.

Let's test some things: & \& &

I typed: It previous as I would expect:

But renders it escaped on the mobile app at least, disappointing...

[–] FlyingSquid@lemmy.world 2 points 1 year ago* (last edited 1 year ago)

It did it without my wanting it to. It won't let me edit it either.