Viewing 14 replies - 1 through 14 (of 14 total)
  • Plugin Author Jeff Starr

    (@specialk)

    I’m not sure but it looks like an issue with how the code is included in the post content. Are you using the Block Editor or Classic Editor?

    Thread Starter ingax

    (@ingax)

    First of all, thanks for making this plug-in! It’s super useful. πŸ™‚

    I’m using the Gutenberg Editor on all my posts. And I’m using the Block Editor.

    I just updated to the latest version of WordPress. Still getting the problem.

    Troubleshooting:

        Posting several other snippets of code in the same code block displays correctly. The problem is specifically with this code snippet.
        Posting the same code on a new post yields the same problem.
        Turning on Code Escaping, for posts, in the Prsimatic preferences fixes the problem. However, author images and other elements no longer display correctly.
        I’m using the latest versions of Autoptimize and W3 Total Cache. Clearing the cache yields the same results.
        I have dozens of pages with code, posted in the same way. This is the only code/page causing issues.
    Plugin Author Jeff Starr

    (@specialk)

    So if I understand correctly:

    • The snippet that you posted above is the only one that is causing problems
    • The problem is resolved when code escaping is enabled
    • When code escaping is enabled there are problems with images and other elements

    Does that sound correct? If so, what exactly is happening with the broken images/markup when escaping is enabled? Does it happen on any other posts/pages/snippets?

    Thread Starter ingax

    (@ingax)

    Correct.

    The main problems I noticed when turning on code escaping was that the author images on the “Recommended For You” posts where not displaying.

    However, I just tested it again. After updating to the latest WordPress, the author images display properly.

    So yay! It looks to be fixed.

    So why did I need to enable code escaping only for this code snippet? And what are the downsides to having code escaping for posts turned on? Will I have to turn on the code escaping for Content, Excerpts, and Comments? Because, if someone posted this same code in the comments, wouldn’t it cause the same issue? Thanks!

    Thread Starter ingax

    (@ingax)

    I spoke too soon. After clearing the cache, the author images do not display. πŸ™

    Plugin Author Jeff Starr

    (@specialk)

    Is there a page where I can view the images not displaying with escaping enabled? I need to be able to look at the markup to see what is happening.

    Thread Starter ingax

    (@ingax)

    Yes. The example page I posted in my first post.

    Plugin Author Jeff Starr

    (@specialk)

    Yeah I checked that. Looks fine to me in latest Chrome browser.

    Thread Starter ingax

    (@ingax)

    The images started showing for me as well. It might have been a cache issue.

    After having escaping enabled for some time, I noticed another problem. All of my previous posts written prior to enabling escaping all have improperly encoded text.

    I turned escaping off because all of my posts display the code properly, except for this one: https://ingax.com/decoding-a-secret-message/

    Some cases are worse than others. In most cases, only the “->” are encoded improperly. In one case, it’s really bad.

    https://ingax.com/daily-coding-problem-61-asked-by-google/

    
    <span class="token keyword">func</span> <span class="token function">pow</span><span class="token punctuation">(</span><span class="token number">_</span> x <span class="token punctuation">:</span> <span class="token builtin">Int</span><span class="token punctuation">,</span> <span class="token number">_</span> y <span class="token punctuation">:</span> <span class="token builtin">Int</span><span class="token punctuation">)</span> <span class="token operator">-</span><span class="token operator">></span> <span class="token builtin">Int</span> <span class="token punctuation">{</span>
      <span class="token keyword">if</span> y <span class="token operator">==</span> <span class="token number">0</span> <span class="token punctuation">{</span> <span class="token keyword">return</span> <span class="token number">1</span> <span class="token punctuation">}</span>
      <span class="token keyword">let</span> power<span class="token punctuation">:</span> <span class="token builtin">Int</span> <span class="token operator">=</span> <span class="token function">pow</span><span class="token punctuation">(</span>x<span class="token punctuation">,</span> y<span class="token operator">/</span><span class="token number">2</span><span class="token punctuation">)</span>
      <span class="token keyword">return</span> y <span class="token operator">%</span> <span class="token number">2</span> <span class="token operator">!=</span> <span class="token number">0</span> <span class="token operator">?</span> <span class="token punctuation">(</span>x <span class="token operator">*</span> power <span class="token operator">*</span> power<span class="token punctuation">)</span> <span class="token punctuation">:</span> <span class="token punctuation">(</span>power <span class="token operator">*</span> power<span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
    

    So back to my initial question. Why is this one snippet of code causing problems? Is it the closures I wrote?

    Thank you!
    David

    Plugin Author Jeff Starr

    (@specialk)

    I don’t know. I tried posting that same snippet on default WP install and there are no escaping issues, everything displays properly. On your setup most likely there is something interfering with normal functionality, could be another plugin, the theme, etc. Difficult to guess without further investigation.

    Thread Starter ingax

    (@ingax)

    I changed the problem page to a default code block for now. I’ll continue to dig through the code to see what’s going on. Thanks for your help!

    Plugin Author Jeff Starr

    (@specialk)

    Alright sounds good. I’ll go ahead and leave this thread open for awhile in case you find something, further questions, etc. Thank you @ingax.

    Plugin Author Jeff Starr

    (@specialk)

    Hi @ingax, just wanted to follow up with this. It’s been awhile with no reply, so I hope the issue is resolved? Or if there is anything I can do to help, please let me know. Thank you.

    Plugin Author Jeff Starr

    (@specialk)

    Hey @ingax, I hope you got this sorted. It’s been awhile with no reply so gonna go ahead and mark this thread as resolved to help keep the forum organized. Feel free to post again with any further questions or feedback, Thank you.

Viewing 14 replies - 1 through 14 (of 14 total)

The topic ‘Code Escaping Problem – Only with one post so far.’ is closed to new replies.