Hello,
I was looking at my site source as I’m tidying it up for PageSpeed reasons. I noticed that the plugin has a <link> tag to a stylesheet, immediately followed by inline styles. This happens on every page, whether I use the code block/your plugin or not. Is there any reason to have it included on every page?
]]>Document says that we can override default but not, because the init() function calls register_editor_assets() directly and ‘syntaxHighlightingCodeBlockType’ declared with ‘const’ so that we cannot override ??
Please just add hook for default attributes,
syntax-highlighting-code-block.php:191
function init() {
......
$attributes = [
'language' => [
'type' => 'string',
'default' => '',
],
'highlightedLines' => [
'type' => 'string',
'default' => '',
],
'showLineNumbers' => [
'type' => 'boolean',
'default' => false,
],
'wrapLines' => [
'type' => 'boolean',
'default' => false,
],
];
$attributes = apply_filters( 'syntax-highlighting-code-block-attributes', $attributes );
......
}
And languages ( not every sites needs All supported languages ?? )
syntax-highlighting-code-block.php:460
function get_language_names() {
$languages = require __DIR__ . '/language-names.php';
return apply_filters( 'syntax-highlighting-code-block-languages', $languages );
}
Thanks in advance
]]>Hi,
Thanks for this wonderful plugin. I’m using it for some time now but I do wonder how I can add a copy button to the code snippets for easy copying.
Looking forward to your reply,
Are there any plans to make the highlighting work in editor as well?
]]>Like from screen, css style is in html instead of header.
Not a giant problem, but if im not in error isn’t the right way.
Hi,
I’m using this great plugin since two years in my posts.
Since more and more comments are posted with code examples (especially YAML) I would like to know if and how you can also format code in comments with it.
Best,
Markus
With the AISEO plugin active the code blocks fail to be styled, no CSS is output to the page source.
]]>The plugin ads HTML pre and code tags, and locks the Gutenberg toolbar in between. This makes selecting and editing posts near impossible.
]]>Hi Weston,
Love this plugin, especially because it uses WordPress’ native code blocks. The only thing missing is the convenient “Copy” button that usually accompanies code snippets. Do you think this is something that could be added in the future?
Keep up the excellent work and thanks for sharing this with the community.
]]>I put here the error:
[Wed Oct 13 18:50:11.820490 2021] [php7:error] [pid 2454232] [client 111.222.333.444:12496] PHP Fatal error: Uncaught Error: Call to undefined function Highlight\\mb_strtolower() in /var/www/blog.carlesmateo.com/wp-content/plugins/syntax-highlighting-code-block/vendor/scrivo/highlight-php/Highlight/Highlighter.php:331\nStack trace:\n#0 /var/www/blog.carlesmateo.com/wp-content/plugins/syntax-highlighting-code-block/vendor/scrivo/highlight-php/Highlight/Highlighter.php(389): Highlight\\Highlighter->keywordMatch()\n#1 /var/www/blog.carlesmateo.com/wp-content/plugins/syntax-highlighting-code-block/vendor/scrivo/highlight-php/Highlight/Highlighter.php(466): Highlight\\Highlighter->processKeywords()\n#2 /var/www/blog.carlesmateo.com/wp-content/plugins/syntax-highlighting-code-block/vendor/scrivo/highlight-php/Highlight/Highlighter.php(579): Highlight\\Highlighter->processBuffer()\n#3 /www/blog.carlesmateo.com/wp-content/plugins/syntax-highlighting-code-block/vendor/scrivo/highlight-php/Highlight/Highlighter.php(823): Highlight\\Highlighter->processLexeme()\n#4 /var/www/blog.carlesmateo.com/wp-content/plugins/syntax-highlighting-code-block/vendor/scrivo in /var/www/blog.carlesmateo.com/wp-content/plugins/syntax-highlighting-code-block/vendor/scrivo/highlight-php/Highlight/Highlighter.php on line 331
]]>
Hello,
I have tried all the options and also disabled my cache plugin, but all the code is shown in one line. could you please help me?
Best regards,
]]>Hey Weston,
I noticed that with the use of more and more code blocks with syntax highlighting, transient entries in wp_options
are piling up into the hundreds.
I don’t have deep understanding of blocks and why transients are needed to render code blocks with syntax highlighting. I just wanted to ask to review that part of the code and maybe find an alternative.
Thanks again for this great plugin!
Thomas
Hi, I use your plugin almost a year, there was no problem with it, but now this duplicates last characters of every word.
Here is an image to see it: https://imgur.com/a/Nd34YZc
On the left side there is my website, on the right side there is Default Gutenberg Editor.
This is not conflict with other plugin, because I didn’t update anything in the last 1 year.
If I deactive your plugin, the duplicated characters disappear.
After this bug I updated your plugin, but the problem is still valid.
Can you help me?
Thank you!
]]>I really like this plugin and it works smoothly. But is some cases the plugin fails to function properly.
For example, in some of the pages in my website, the highlighted code is displayed as shown below:
Dim char1, char2 As Char
Code language: VB.NET (vbnet)
Could you please tell me why this is happening? Please note it only happens in few of my pages.
]]>Testing this update on a staging install. Ran into two bugs.
WP v5.6
this plugin v1.3
Bug 1 – Can’t paste XML or HTML into the Code block when this plugin is activated. It basically pastes in a blank line.
Note: If you change the block to “Edit as HTML” and try pasting into that, you end up with the “Invalid block” error. So your only option is to manually type in the code.
Bug 2 – This issue is now happening with XML Unexpected line number appearing on same line #193
I had a page with XML in a code block. I updated to 1.3. Then looked at this page. It now has the “unexpected line number” problem in the code block with XML in it. It didn’t have this problem in the previous version (1.2.3). To doublecheck, I reinstalled the previous version and verified that the problem wasn’t there.
I have this XML on the page:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="https://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true">
</nlog>
Due to bug #1, you have to manually type in the XML. Here is the simplest way to repro this:
1. Create a new page
2. Add a code block
3. Manually type in this XML:
<?xml version="1.0" encoding="utf-8" ?>
<tag a="t"
b="t">
</tag>
4. Use the following settings:
* Language = HTML, XML
* Show Line Numbers = true
* Wrap Lines = true
Hi,
I installed the plugin and I have many code tags, but I can’t see any change!!
What should I do to make the server rendering work?
Regards,
]]>Is there an easy migration path from mkaz’s Code Syntax Block plugin to yours? Code blocks are broken since I disabled ‘Code Syntax Block’ and need to be converted. I don’t want to edit hundreds of posts manually with possibly even more code blocks.. ??
What I have now is, for example
<!-- wp:code -->
<pre class="wp-block-code"><code lang="powershell" class="language-powershell">Get-SmbServerConfiguration | Select EnableSMB1Protocol</code></pre>
<!-- /wp:code -->
And this needs to be converted into:
<!-- wp:code {"language":"powershell"} -->
<pre class="wp-block-code"><code>Get-SmbServerConfiguration | Select EnableSMB1Protocol</code></pre>
<!-- /wp:code -->
BTW: I tried to use John Godley’s Search Regex plugin, but that broke more than it fixed… A kind of working regexp is:
s/<!-- wp:code -->\n<pre class="wp-block-code"><code lang="\(.*\)" class="language-.*">/<!-- wp:code {"language":"\1"} -->\r<pre class="wp-block-code"><code>/
But I like a more fail-safe migration path ?? I’ll update this support question if I find a solution in the meantime.
]]>Hi there. Thanks for the great plugin.
Using the latest version of Gutenberg seems to conflict with this plugin. The code block was a little messed up, and when I disabled Gutenberg to fix it, the code blocks were invalidated and I had to do some simple conversion to get them back working.
Also I have a feature request. Can you please add a rel
attribute for the language so we can style the language output like: https://gist.github.com/ronalfy/2dbb84ceee04328d6bca98b21df7fb1c
Thanks a lot.
Ronald Huereca
]]>I ran into a bug when setting the language to Java and showing line numbers.
I put this in the code block:
public QuoteEntity(@NotNull String text)
It gets rendered like this:
1| public QuoteEntity( 1| @notnull String text)
Options:
Language=Java
Show Line Numbers = true
How can I change defaults? I saw in the documentation about adding “add_action(“init”) in functions.php, but that didn’t seem to work.
I may just need to mod the php files in the plugin, but I’d like to avoid that since that will be more work in the future to keep it synced with the main repo.
]]>* Very few syntax colors. I’m using Python. Built-in functions are black; variables are grey; comments are grayer, only the strings had some color. 4 colors in total: Black, Grey, Green, Red
* No settings to customize themes. Only one built-in theme.
* Couldn’t highlight the bash commands at all.
* If I want to use line numbers, then I have to go through each of the code blocks and turn on the line number option, which is weird.
* Missing the most common functionality, which is a COPY code option for viewers in a code block.
* The only good thing I found is that it’s lightweight and AMP compatible. The ONLY plugin that automatically supports (very basic) syntax highlighting.
Looking for these features. Deactivated the plugin for now, but will soon check if these features are added or not.
]]>Hi,
I’m using Autoptimize on my site to minify the HTML, CSS, and JS. If I use the “Syntax-highlighting Code Block”, Autoptimize leaves an unreplaced %MINIFYHTML% placeholder inside the code block on the website’s frontend.
Never saw this before in any other block. I’m not sure, if this has to be fixed in your plugin or in the Autoptimize plugin.
It looks like %MINIFYHTML43903717bc81998ee44729dd57469a6617%
<pre class="wp-block-code">
%MINIFYHTML43903717bc81998ee44729dd57469a6617%
<div>
<code class="hljs language-apache shcb-code-table shcb-line-numbers shcb-wrap-lines"><span class="shcb-loc"><span><span class="hljs-attribute"><span class="hljs-nomarkup">RewriteEngine</span></span> <span class="hljs-literal">On</span>
</span></span>
</code>
</div>
</pre>
Link to Autoptimize: https://www.ads-software.com/plugins/autoptimize/
]]>Hi,
First of all, thank you for the amazing plugin!
When I add the Apache config (.htaccess block) something breaks syntax.
Here is the sample code:
RewriteCond %{QUERY_STRING} (<|%3c)(.*)(s|%73|%53)(c|%63|%43)(r|%72|%52)(i|%69|%49)(p|%70|%50)(t|%74|%54)(.*)(>|%3e) [NC,OR] RewriteCond %{QUERY_STRING} (\+|%2b|%20)(d|%64|%44)(e|%65|%45)(l|%6c|%4c)(e|%65|%45)(t|%74|%54)(e|%65|%45)(\+|%2b|%20) [NC,OR] RewriteCond %{QUERY_STRING} (\+|%2b|%20)(i|%69|%49)(n|%6e|%4e)(s|%73|%53)(e|%65|%45)(r|%72|%52)(t|%74|%54)(\+|%2b|%20) [NC,OR] RewriteCond %{QUERY_STRING} (\+|%2b|%20)(s|%73|%53)(e|%65|%45)(l|%6c|%4c)(e|%65|%45)(c|%63|%43)(t|%74|%54)(\+|%2b|%20) [NC,OR] RewriteCond %{QUERY_STRING} (\+|%2b|%20)(u|%75|%55)(p|%70|%50)(d|%64|%44)(a|%61|%41)(t|%74|%54)(e|%65|%45)(\+|%2b|%20) [NC,OR] RewriteCond %{QUERY_STRING} (\\x00|(\"|%22|\'|%27)?0(\"|%22|\'|%27)?(=|%3d)(\"|%22|\'|%27)?0|cast(\(|%28)0x|or%201(=|%3d)1) [NC,OR] RewriteCond %{QUERY_STRING} (g|%67|%47)(l|%6c|%4c)(o|%6f|%4f)(b|%62|%42)(a|%61|%41)(l|%6c|%4c)(s|%73|%53)(=|[|%[0-9A-Z]{0,2}) [NC,OR] RewriteCond %{QUERY_STRING} (_|%5f)(r|%72|%52)(e|%65|%45)(q|%71|%51)(u|%75|%55)(e|%65|%45)(s|%73|%53)(t|%74|%54)(=|[|%[0-9A-Z]{0,2}) [NC,OR] RewriteCond %{QUERY_STRING} (j|%6a|%4a)(a|%61|%41)(v|%76|%56)(a|%61|%31)(s|%73|%53)(c|%63|%43)(r|%72|%52)(i|%69|%49)(p|%70|%50)(t|%74|%54)(:|%3a)(.*)(;|%3b|\)|%29) [NC,OR]
Thanks in advance!
Best regards.
I am not sure but can this plugin stop FOUC? I can not solve this issue for a long time.
Can you give me some info on how can I stop fouc?
]]>Hi,
We are implemented the code snippet support. We are having the razor code example formats. In this plugin no support for razor cshmtl language. Any way to add the razor language repository in this plugin.
Repository – https://github.com/highlightjs/highlightjs-cshtml-razor
Kindly help me to add this into my plugin.
Regards,
Raj S
I have tried to add the add filter block as shown described. But its not working.
Could you please let me know how i can change the background colourto white atleast?
]]>is it possible to use the plugin with <pre>
tag
Thanks
Hi,
2 questions,
1. I am using the oceanwp theme and the Color options in the Customizer is not showing. How do I change the theme colors now?
2. Is there a way to use this inside Elementor? I have tried creating a HTML block with
blocks, but it does not work.
Many thanks
Ryno
I guess that I will be the first to post a support question …
I have been looking a long time for the perfect plugin to post shell and code snippets on my website. The Syntax-highlighting Code Block is the best one that I have found so far. However, I am seeing a small issue.
I added the filter to select the Xcode style for the server-side rendering engine. It works perfectly in Google Chrome, Firefox, and Microsoft Edge. When I have long lines that are longer than the code block width, the code block scrolls the line. That was the effect that I was hoping for.
But for some reason, this does not work in macOS Safari. The long lines just wrap in the block window. Does anyone have any ideas about why this happens?
]]>