Posting source code bugs
-
Having some bugs posting Java source code as seen in
https://en.support.wordpress.com/code/posting-source-code/[code language=""java""] Set<String> strings; [/code]On save
<String>is deleted, probably because it is mistaken for HTML. I tried different options in the shortcode without any difference.
< >cause problems as well and are not readable.I believe this is a plugin and the bug should be filed there, but is there anything that can be done here to avoid it (like another source plugin).
The blog I need help with is: (visible only to logged in users)
-
The sample in the post above got messed up in this forum (even though it is marked source). Is it because of the same bug?
should be “java” and not “”java””
should be
Set<String>
instead of
Set<String>Crossing fingers you can see my changes.
-
-
Hi there,
If you format like that:
https://pastebin.com/raw/DpV1kqt4
the code will be properly highlighted.
Also, make sure to use the HTML editor when using that shortcode.
-
I tried that snippet, and <String> was removed. Do a preview and you will notice it is missing.
-
Hi there,
Have you by any chance been switching between the HTML and visual editors while working on this post? This sounds similar to an old bug that was fixed a while ago: https://github.com/Automattic/wp-calypso/issues/1426
Can you please give us the exact steps you’re following to add the code, and a link to the post where you’re adding it? Also add the code itself to a gist or a pastebin so we can see the original code – it looks like the forum might also be stripping some of it out in spite of using the code tags here.
Can you lastly please check if it makes any difference whether you use the editor in the WP-Admin dashboard vs the one in My Sites?
-
I tried only in HTML Editor.
To replicate:
1. Click “My Site” > “Site Pages” > Add
2. Change editor to HTML
3. Paste the code from pastebin above
4. Click Preview
5. <string> is gone from the preview.
6. Close preview. The editor still shows <string>
7. Save and close
8. Open again in HTML editor
9. <string> is now also removed from the code block. -
I am using the pastebin above by fstat as it is short and replicates the problem. So no need for a new pastebin.
I hope admins can access the page since it is still in development and not public:
https://wordpress.com/page/jetstream4j.wordpress.com/153Same behaviour in admin dashboard.
This forum shows the same bug by the way, here is the pastebin:
[code language="java"]
set<string> strings;
[/code] -
Oddly enough it is escaped, but still not correct. I did get this escaping in my site after editing the page a few times, and also double escaping where the escaped code is escaped again.
-
Can you try it from the WP Admin page/post editor and see if that works? That will let us know if it is a problem just in the Calypso side of things, or in the wp-admin editor as well.
-
-
First, it should make no difference whether you use the HTML or the visual editor when using the code-shortcode. Just mentioning that for future reference.
The code disappearing after Save or Publish is a known issue:
https://github.com/Automattic/wp-calypso/issues/22432
I’ll add your report there, but until it’s fixed the best option here is to use WP-Admin instead for any post where you’re posting source code.
-
No, scratch that.
Can you please check what happens if you put a space between “set” and the HTML entity for the <, and update the page? If I do that, nothing is getting stripped, and it correctly displays the code in the published version.
-
Space between “set” and “<” still exhibits the problem.
Add space, save, preview, the HTML like code is gone from the editor.
-
Thanks for the verification. I would suggest using the WP Admin editor for now until this can be fixed.
- The topic ‘Posting source code bugs’ is closed to new replies.