syntax-highlighted Source code is mangled after editing post
-
Hi,
when adding a syntax highlighted code block, I use
[code lang="cpp"]
// code here
[/code]After I submit the post, if I want to go back and edit it, all of the <, >, &, and ” characters get converted into < > & "
So if I edit the post with those replaced characters and then resubmit my edits, WordPress ends up publishing no longer ‘<‘ but the actual text ‘<‘
So then the code is all messed up!! It should not be this way.. When I edit the post, I should be able to edit in place, wordpress should fix these issues..
My current work around is to manually copy the entire post into a text editor, and do a find->replace for < etc. and replace the codes with their original characters. So tedious and unnecessary.. Please fix
The blog I need help with is: (visible only to logged in users)
-
-
I tagged this thread for Staff assistance with your pôsting source code issues. Please subscribe to it so you are notified when they respond. To subscribe look in the sidebar of this thread, find the subscribe to topics link and click it.
-
-
I really need this plugin so that I can put C# code and XAML snippets in my blog or it is utterly useless.
https://wordpress.org/plugins/syntax-highlighter/installation/ -
-
@chrisahill1 – We already have a syntax highlighter:
http://en.support.wordpress.com/code/posting-source-code/
If you need help with that, please open your own thread:
https://en.forums.wordpress.com/?new=1
@bazz1 – Can I get a link to a post where you’re having this problem so I can take a look? Are you editing in the dashboard editor or the legacy editor?
-
@shawnajroberts I am using the dashboard editor, and I have recorded a full-length video fully illustrating the problem at hand.
http://youtu.be/zgXsQFW9SaA
[ the video is almost done processing.. it should be done by the time you view it ]I listed the problematic characters (< > ” &) I have run into personally in the video, but there may be others out there that I’m not aware of (ie. single quotes?)
I’m no WordPress expert, but here’s my idea of a solution that might be helpful: when going to edit the blog post, replace all HTML codes found in the post to their regular characters in the post editor.
-
Thanks so much for that walkthrough! I’ve passed it along to our developers along with my own testing of the issue. This seems to be happening both inside and outside of the code tags. :(
In the meantime, the legacy editor in wp-admin does not have this issue. You’ll probably have better luck editing there for the time being.
I’ll let you know as soon as I hear back from the developers about this.
-
Ah so the problem transcends the plugin! Interesting! This is an important fix then! :) I’m excited! lol
I’ll see about accessing the legacy editor, and I’m looking forward to your update! ^_^
-
Hi Shawnajroberts,
It’s been about a month, so I was wondering how is the status on this bug fix?
Sincerely,
bazz -
I don’t have an update for you, but I’ve just pinged a developer to get some eyes on it. I’ll let you know as soon as I hear back about this.
-
Hi bazz1,
I had the same problem and found this blogpost which identifies Markdown causing the problem. So I disabled Markdown (see here on how to enable/disable Markdown). When I’m editing a blogpost I also make sure not to use the visual editor but the text editor. I hope this helps.
- The topic ‘syntax-highlighted Source code is mangled after editing post’ is closed to new replies.