Code Block Rendering Issue After Page Refresh in Prismatic 3.5
-
I’ve noticed an issue with the latest version of Prismatic (v3.5). When refreshing the page, there’s a brief moment where the code content appears outside of the code block before it snaps back into place. This behavior wasn’t present in earlier versions.
It’s a minor but noticeable glitch in the user experience. Is this a known issue? Could this be fixed in an upcoming patch?
Thanks in advance!
See video example:
-
Glad to help.
I am not seeing this issue on default WordPress, but if you can provide the basic steps to repeat, I can investigate asap. So steps would be clear and easy to follow for example:
- Install WordPress
- Install/activate Prismatic
- Change such and such plugin settings
- Add some code and wrap with pre tags
- Visit the page on the front end
- Etc., until the issue happens
That way I can follow along and try to help asap, thank you.
Hey worldsdream, I hope you got this sorted. It’s been a while 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.
Hi Jeff,
I downgraded the prismatic plugin to version 3.4.4 and kept using it. I tried again with the new version 3.6 and it has the same bug as version 3.5.
When refreshing the page, there’s a brief moment where the code content appears outside of the code block before it snaps back into place. This behavior wasn’t present in earlier versions.
I installed it in a fresh WP install and I can reproduce this behavior every time.
- I have the default 2025 theme.
- I use prism.js only
- Create a new post and add a new prismatic block and add the code below and save the post.
/* **********************************************
Begin prism-core.js
********************************************** */
/// <reference lib="WebWorker"/>
var _self = (typeof window !== 'undefined')
? window // if in browser
: (
(typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope)
? self // if in worker
: {} // if in node js
);
/**
* Prism: Lightweight, robust, elegant syntax highlighting
*
* @license MIT <https://opensource.org/licenses/MIT>
* @author Lea Verou <https://lea.verou.me>
* @namespace
* @public
*/
var Prism = (function (_self) {
// Private helper vars
var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
var uniqueId = 0;
// The grammar object for plaintext
var plainTextGrammar = {};
var _ = {
/**
* By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
* current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
* additional languages or plugins yourself.
*
* By setting this value totrue, Prism will not automatically highlight all code elements on the page.
*
* You obviously have to change this value before the automatic highlighting started. To do this, you can add an
* empty Prism object into the global scope before loading the Prism script like this:
*
*js<br> * window.Prism = window.Prism || {};<br> * Prism.manual = true;<br> * // add a new <script> to load Prism's script<br> *
*
* @default false
* @type {boolean}
* @memberof Prism
* @public
*/
manual: _self.Prism && _self.Prism.manual,
/**
* By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
*addEventListenerto communicate with its parent instance. However, if you're using Prism manually in your
* own worker, you don't want it to do this.
*
* By setting this value totrue, Prism will not add its own listeners to the worker.
*
* You obviously have to change this value before Prism executes. To do this, you can add an
* empty Prism object into the global scope before loading the Prism script like this:
*
*js<br> * window.Prism = window.Prism || {};<br> * Prism.disableWorkerMessageHandler = true;<br> * // Load Prism's script<br> *
*
* @default false
* @type {boolean}
* @memberof Prism
* @public
*/
disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler,
/**
* A namespace for utility methods.
*
* All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
* change or disappear at any time.
*
* @namespace
* @memberof Prism
*/
util: {
encode: function encode(tokens) {
if (tokens instanceof Token) {
return new Token(tokens.type, encode(tokens.content), tokens.alias);
} else if (Array.isArray(tokens)) {
return tokens.map(encode);
} else {
return tokens.replace(/&/g, '&').replace(/</g, '<').replace(/\u00a0/g, ' ');
}
},
/**- Go to the post front-end and refresh the page.
I recorded a GIF with what is happening > GIF (give it some seconds for it to load because I didn’t refresh immediately in the browser).
I uploaded the Prismatic settings > image1 image2 image3 image4 image5
Let me know if you need more information to get to the bottom of this! Thanks.
Thanks for the detailed information. I followed along using the same settings and theme, set the language as PHP, added the code snippet and there was no flash of code/content. I tried reloading the page several times using Chrome on macOS, the code displayed normally.
Just guessing, the issue could be with the browser and/or OS that are being used.. something to experiment with if you haven’t already done so. Also, have you tried other languages, code snippets, and themes? Maybe some further clues to be found..
Thanks for testing it on your end.
I have tried it on Firefox, Edge, and Chrome. I also have tried different languages from the dropdown menu in Prismatic. The result is the same on all of them.
It happens with all themes. All plugins are disabled. I also tested it on a clean WordPress install with only the Prismatic plugin installed. I tested it in both a local environment and a cloud environment.
The last version where this bug did not appear was 3.4.4. After that, it started occurring.
So it is definitely a change in the plugin that is causing this. If you are unable to fix it, please let me know, and I will switch to another plugin.
Thanks.
I definitely want to resolve any issue, but first need to be able to replicate it on default WordPress installation. So far I am unable to do so. You are more than welcome to use any plugin you wish if this plugin is not working on your site. I will go ahead and leave this topic open in case anyone else happens to encounter this same issue (so far this is the only report), maybe further clues will be discovered in the future.
Jeff, I am using a Windows environment and it might be that. Did you try it on a Windows system for example?
Definitely could be related to Windows/OS.. however I currently cannot test on Windows as my PC laptop died earlier this year.
Maybe this will help, I set up a test page where you can view a Prism.js code snippet on your device. Check it out here and let me know the results.
Thanks, Jeff. Can you please add more code to the horizontal lines? Because it’s difficult to test like this.
So the issue happens only when the code overflows beyond the width of the pre element? That in and of itself is an informative clue.. and yes I will add longer lines of code once I get back to the office.
Okay updated the first code block with longer lines, and also added a second code block containing your example from previous post.
Thanks, Jeff. I tested it out and I can’t reproduce it on my Windows system. Very weird.
Ok thank you for looking into it. Please let me know if it happens again. Take care.
You must be logged in to reply to this topic.