Why does the custom HTML block not preserve the HTML characters?

For example it seems that the plain single-quote character ' (#x27;) is converted to the right ones (#8217;) in the HTML page output. I understand the reason for this in regular Gutenberg blocks, but why does it still need to be done in the custom HTML block? I enable troubleshooting mode and use the Twenty Twenty-One theme and it's still converting.

Here are the different between the input methods:

pParagraph block then converted to html: #8216;/p
Custom HTML block: #8216;
pre class=wp-block-preformattedPreformatted block: '/pre
pre class=wp-block-codecodeCode block: '/code/pre
preClassic block with preformatted style: '/pre

My goal is to preserve the characters so that I can make inputs for Cypher. A piece of JS is in the post to handle this input.

FYI: A piece of JS code is needed to use multiple times with different values and function names. How to do it efficiently?

Topic block-editor htmlspecialchars-decode troubleshooting html-editor Wordpress

Category Web


This is caused by wptexturize and the use of a standard <div> to contain your code. See https://developer.wordpress.org/reference/functions/wptexturize/

Instead, markup code as code:

Text enclosed in the tags <pre>, <code>, <kbd>, <style>, <script>, and <tt> will be skipped. This list of tags can be changed with the no_texturize_tags filter.

Note that the HTML block just allows you to insert user defined HTML into the post content, that post content still gets processed, it's a block with HTML, not a raw arbitrary HTML block, e.g. if you put a shortcode inside it, the shortcode gets processed. A paragraph inside a HTML block is just as much a paragraph as a paragraph inside a paragraph block. Likewise you might discover some tags get stripped out if you don't have the unfiltered_html capability

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.