How can I do syntax highlighting for files included with a custom shortcode?

I'm writing a tutorial on using the R language to do some applied statistics. An example post is: http://mcmcinirt.stat.cmu.edu/archives/223 This answer taught me how to develop a custom shortcode so that I can include files stored on the webserver directly into the post. It works great. However, if possible, I'd like to have syntax highlighting too instead of 'just' the <pre> tag rendering. My initial attempt was to change the output of the shortcode function from: return '<pre>'.$file.'</pre>'; to return …
Category: Web

Wordpress 5.1 and Syntax highlighter, problem with HTML encoded special characters

I'm using Wordpress 5.1 and Gutenberg block editor. I'm trying to show some Java code with the plugin SyntaxHighlighter Evolved. When editing a post I use the block 'Custom HTML' then add the code [code language="java"] List<Integer> myList = new ArrayList<>(); [/code] Then I save the post and the Java code will appear correctly with syntax highlighting applied to it. It will look like this This is the result that I wanted. But a problem happens when I edit the …
Category: Web

Proper implementation/use of code/syntax highlighting

I've already read what I can on a couple of sites and installed this plug-in: http://en.support.wordpress.com/code/posting-source-code/ http://alexgorbatchev.com/SyntaxHighlighter/ I'm missing how to make it work. Now I have two questions: Do I have to type in the Visual window or the HTML window? Does TinyMCE mess with this? I've seen my code disappear in the HTML window. I currently have typed in my code in Visual Window like this: [sourcecode language="php"] <? Header( "HTTP/1.1 301 Moved Permanently" ); Header( "Location: http://CMSTrainingVideos.com" …
Category: Web

Visual Editor not working properly

I have facing this issue since last one month. I would like to display my source code using the Syntax Highlighter so i have changed my editor mode from visual to text. I put my code in [html] <div class="panel panel-default panel-faq"> <div class="panel-heading"> <a data-toggle="collapse"> <h4 class="panel-title"> Questions </h4> </a> </div> </div> [/html] Then i switched to visual mode then the editor is give a new line space between the html code. like bellow. [html] <div class="panel panel-default panel-faq"> …
Category: Web

My Syntax Highlighter Died, What Now?

On my wordpress install (hosted by 1&1) a few years back I installed "Syntax Highlighter for WordPress" (I'm currently at 3.0.83.3) Everything was going great until yesterday when something got updated and now my syntax highlighting doesnt work. I can see when "view source" that the <pre> tag that is created by my [cpp] tag is immediately closed on the same line instead of waiting for the [/cpp] tag. It's a bit strange. Anyways, I went to check if there …
Category: Web

Problem with the position of SyntaxHighlighter Evolved javascript

Hello i use SyntaxHighlighter Evolved (http://wordpress.org/plugins/syntaxhighlighter/description) and it's load their script after </html> tag. i want to put the script of this plugin before the </html> tag in pages. you can see this issue online here. http://rokesh.ir/tutorial-adding-sharing-buttons-on-social-networks-to-wordpress-contents
Category: Web

Disable escaping html

I'm using SyntaxHighlighter Evolved to highlight code examples. E.g. [csharp] string s = "text"; List<int> numbers = new List<int>(); [/csharp] When I first save it, it's ok, but when editing wordpress changes the text to [csharp] string s = "text"; List<int> numbers = new List<int>(); [/csharp] After second edit it becomes [csharp] string s = "text"; List<int> numbers = new List<int>(); [/csharp] How do I disable escaping? I want the content to be exactly what I type.
Category: Web

Create custom [sourcecode] shortcode, the right way?

What I want to do Sharing code in posts on WordPress is quite a pain with all the HTML escaping to take care of. So, I plan to enclose code in posts within a custom shortcode called [sourcecode], as shown below, and let it automatically escape the special characters. [sourcecode] <?php // Some code here. ?> [/sourcecode] The code And this is what the relevant function (in my theme's functions.php) looks like: /** * Functionality to set up custom shortcode …
Category: Web

Syntax Highlighter XML striping

I am really frustrated with availible Syntax Highlighter's on the market it seems that no matter which one I use, after pressing "Save Draft" or "Publish" and after I change from Visual to Html or reverse I am loosing the xml snippet code. Also, other code (C#, PHP) just loosing their style, especially break lines making code unreadable. My configuration is WordPress 3.2.1. Easy Google Syntax Highlighter, SyntaxHighlighter TinyMCE Button, SyntaxHighlighter I really like WordPress however writing and espessially editing …
Category: Web

Convert [xcode]foo[/xcode] to <pre>foo</pre>

I'm converting vBulletin content to WP with the Crayon syntax highlighter. What is the best way to convert the content's [xcode]foo[/xcode] to &lt;pre class="lang:default decode:true "&gt;foo&lt;/pre&gt; for Crayon? I see info about the Crayon legacy tags conversion but the screenshots are missing and I don't know how to enable "legacy tags" for Crayon.
Category: Web

How to filter PHP opener?

I've been searching the web and in this great forum but I didn't find anything. I got some issue with a code higlighter plugin. Everything is fine except that some php tags do not work properly : &lt;!--?php instead of &lt;?php It just breaks markup ! I only use HTML Editor. How can I manage to make it work? EDIT: in the meantime I just changed plugin and it works fine but I'm curious to know how to solve this …
Category: Web

How can I highlight specific pieces of text within a blog post?

I have searched for a simple method to allow a user to highlight a specific piece of text with a user chosen color but have not found one readily apparent. I have found a few methods related to syntax / code highlighting. I am not trying to highlight code but merely text within a blog post. Preferably I would like a simple method that provides a UI button within the editor itself as some users that post articles are not …
Category: Web

code highiglight not working comment

SyntaxHighlighter Evolved plugin installed on my blog. Code highlight working on post,but no comments.. I am showing the comment form with the different codes : &lt;form method="post" name="commentform" onsubmit="return false" id="commentform"&gt; &lt;textarea name="comment" id="commentr" cols="50" rows="10" tabindex="4"&gt; &lt;/textarea&gt; &lt;input type="hidden" name="send" id="send" value="1" /&gt; &lt;span class="t"&gt;&lt;/span&gt; &lt;input type="submit" class="sendmain" name="sendmain" onclick="_sendmain('&lt;?php echo $post-&gt;ID; ?&gt;');" value="Send" /&gt; &lt;/form&gt; What do you think the problem? My English is bad, I'm sorry. Thanks..
Category: Web

Any good desktop client for wordpress with support for google syntax highliter?

I'm using Google Syntax Highlighter for WordPress and I have to go to the html view where I have to manually type the tags for pasting code and formatting gets messed up when I switch back to the WYSIWYG view. Is there a desktop client like windows live writer that has support for Google Syntax Highlighter and allows us to paste code and format the post in the same view?
Category: Web

Code Formatted with SyntaxHighlighter Evolved Appearing Incorrectly on iPad/iPhone

I have just started a programming blog and I am using the SyntaxHightlighter Evolved plugin to format my code. On most browsers this is working just fine. However if I attempt to view the site from either an iPhone or iPad the line numbers and code are no longer aligned. Basically the problem seems to be that the line numbers and code fonts are sized independently (see image below). I assumed somebody else must have seen the problem so I …
Category: Web

Highlight Syntax Inline

I'm looking for a plugin that is compatible up to the current version of WordPress (3.1.1 as of writing of this question) and that supports some kind of inline highlighting of programming language syntax. Basically, I want to be able to write a function name or a variable name or a quick if statement as part of a paragraph and have it look like code, much like what you get in the StackExchange editor with the backticks. There are several …
Category: Web

About

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