Support » Fixing WordPress » Auto occurring error in code block

  • I write help / how-to articles for phpBB forums on my website. There are some codes. I use the code block for these. However, I noticed a mistake. The “–” in the code block becomes “—” in the published text. So when two short lines come side by side, a long line appears on the website. This causes problems such as the inability to find and the inability to run the code. How can I fix this?

    Here: https://i.ibb.co/QpXRyhB/wwwwwww.jpg

Viewing 4 replies - 1 through 4 (of 4 total)
  • I tested what seems like an HTML comment from your screenshot in the native WordPress editor’s CODE BLOCK, and the code was not changed in any way.

    Please see: https://s-qz5w4cvwbdq7.eu1.wpsandbox.org/testing-code/

    Was my code not representative of your code? Can you give your full block of code so I can test?

    Thread Starter Halil ESEN

    (@halilesen)

    Thank you for your answer. Thinking that this might be related to the theme, I previewed the theme you showed as an example. The problem persisted.

    Of course. For example, I can show the following code.

    <!-- IF U_BOOKMARK_TOPIC -->
    	<li>
    		<a href="{U_BOOKMARK_TOPIC}" class="bookmark-link" title="{L_BOOKMARK_TOPIC}" data-ajax="alt_text" data-alt-text="{S_BOOKMARK_TOGGLE}" data-update-all=".bookmark-link">
    			<i class="icon fa-bookmark-o fa-fw" aria-hidden="true"></i><span>{S_BOOKMARK_TOPIC}</span>
    		</a>
    	</li>
    <!-- ENDIF -->

    I’m using the “Copy Anything to Clipboard” plugin. This is because I blocked the text selection on my site. Could there be a problem?

    I’m using the “Copy Anything to Clipboard” plugin. This is because I blocked the text selection on my site. Could there be a problem?

    I don’t think so. I installed and activated the “Copy Anything to Clipboard” plugin, and put your full code above into a Gutenberg CODE block — and, once again, no transformation took place and the code is exactly as entered in the editor.

    https://s-qskhycy6ldq7.eu1.wpsandbox.org/test/

    Note that the transformation you’re seeing is, indeed, a documented WordPress feature which replaces common plain text characters with formatted entities.

    But, by default, text enclosed in the tags <pre>, <code>, <kbd>, <style>, <script>, and <tt> are supposed to be skipped (ie not transformed).

    The Gutenberg code block uses the <code> tag inside a <pre> tag — so this shouldn’t be happening — unless something on your site is messing with the feature or the HTML tag generated.

    Note that you can turn the entire wptexturize feature off, or customize the list of HTML elements not to texturized via filters.

    Thread Starter Halil ESEN

    (@halilesen)

    Note that you can turn the entire wptexturize feature off, or customize the list of HTML elements not to texturized via filters.

    I added the codes in the link you provided to the functions.php file, but it didn’t work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.