question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get full HTML and have HTML entities not escaped?

See original GitHub issue

Using HtmlParser, I’m changing some nodes. E.g. I’m inserting something like — and other entities.

When accessing the InnerHtml property, the (e.g.) — is returned as —. This is wrong in my scenario.

In contrast, the TextContent returns — correctly but omits all contained HTML tags.

My question:

Is there a way to get the full content of the HtmlParser without HTML entities being “destroyed”?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FlorianRapplcommented, Jul 3, 2016

Thanks Uwe! I’m glad you found a workaround / solution for your problem. Always at your service!

1reaction
FlorianRapplcommented, Jul 3, 2016

Thanks for giving me some context. Yes, from the snippet it seems that this is indeed the problem. The NodeValue is quite a generic property, which maps to nothing except for CharacterData nodes (e.g., comments or text nodes) and entities (which are not used in HTML as they are resolved directly; this is an historic type of node that is a left-over from XML). Hence you already set the literal text (same as setting TextContent).

Either you use the previously mentioned HtmlEntityService to do the conversion yourself, or you leave it up to a parser by parsing a fragment of the snippet you want to insert.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting inner html without escaping or decoding anything ...
For anyone asking this in 2021.. My solution was to take the text in place it in a different textarea using .innerHTML ,...
Read more >
HTML Escape Characters: Complete List of HTML Entities
Number Symbol Entity Name Code Description 9 Tab &Tab &#9 Tab 10 New Line &NewLine &#10 New Line 32 Space &nbsp &#32 Space
Read more >
htmlentities - Manual
When double_encode is turned off PHP will not encode existing html entities. The default is to convert everything. Return Values ¶. Returns the...
Read more >
How to escape & unescape HTML characters in string ...
Escaping HTML characters in a string means replacing the: ... We can escape the HTML of the string using the replace method of...
Read more >
HTML: No, you don't need to escape that - mina86.com
It would make sense to conclude that escaping is required if an ampersand is followed by one of those characters, which is probably...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found