Can’t write a post as WordPress edits my html?
-
I am having the following issue… I am working with some C++ code posted in sourcecode brackets but wordpress is editing it so much that it combines sourcecode with sourcecode further down even though there is a ‘[/sourcecode] inbetween. The code and text between completely disappears.
The following blog post would combine the two sourcecodes together, and both code and writing gets lost between ‘< std::endl; break; } lcm += lcmHost;' and 'b) ? a : b; //Make it an endless loop to check many.':
C++: LCM of two numbers
To produce our ‘until’, we simply say do this loop forever (while true), stop searching (break lets us out of loop) if you find lcm (if statement holds true), else the current number isn’t the lcm, so add the next possible lcm (multiple of the highest number).
[sourcecode language='cpp']
while (true) {
if (lcm%a == 0 && lcm%b == 0)
{
std::cout << 'LCM of ' << a << ' and ' << b << ' is ' << lcm << '.' < b) ? a : b;//Make it an endless loop to check many.
while (true) {
//The common multiple happens when mod function returns 0, so it will be LCM if both return 0
if (lcm%a == 0 && lcm%b == 0)
{
std::cout << 'LCM of ' << a << ' and ' << b << ' is ' << lcm << '.' <<
std::endl;
break;
}
//If it’s not so, we must go onto the next number to check if that is the LCM
//It needs to be the next multiple of highest number, nothing in between will work.
lcm += lcmHost;
}[/sourcecode]
The blog I need help with is: (visible only to logged in users)
-
Okay it edited it here as well, I don’t know what to do? There is stuff between those two lines.
The line should be
std::cout << "LCM of " << a << " and " << b << " is " << lcm << "." <<std::endl; -
And then the line where it goes back is
//check which one is the higher number, since that is the lowest possible right now. lcmHost = lcm = (a > b) ? a : b; -
-
https://i.imgur.com/NiU6eLI.png
I realise this is most likely html, but I don’t know much of html so how do I avoid this issue?
-
I believe this might tell a better story of my problem, since it isn’t as easy to post pictures here and I can’t even delete or edit a reply, doesn’t feel like 2019 at all..
-
-
@eight84 Hi The two codes work separately as blog posts but I want them to be together as a blogpost. To reproduce my issue you would copy the start of the first snippet of code to the end of the next snippet of code, where the dots represent the part inbetween:
“[sourcecode language="cpp"]
while (true) {
if (lcm%a == 0 && lcm%b == 0)
{
………………………………………….
//If it’s not so, we must go onto the next number to check if that is the LCM
//It needs to be the next multiple of highest number, nothing in between will work.
lcm += lcmHost;
}[/sourcecode]“
-
Here are the results I am getting with the block editor:
Two blocks of code in one post: Test 1
One block of code with both snippets included inside (also in one post): Test 2
Using the Classic Editor, however, this was my result: https://cl.ly/48401809dfc0
I see what you are saying. Have you tried switching to the block editor to create your post?
-
Actually, in the Classic Editor, I also used “
” around the sourcecode tags. Which rendered similar results to the block editor.HTML: https://cl.ly/6bf8f1019624
Result: https://cl.ly/6fac3f5d5f8bIs this what you were looking for?
-
-
Hi there, is this the guide you’re using to posting your source code here on WordPressdotcom? https://en.support.wordpress.com/code/posting-source-code/
-
@eight84 Thanks for that I’ll try to put the code tags maybe it will help, since I’m quite new I don’t see a block editor option.
@justjennifer Thats the one yes.
- The topic ‘Can’t write a post as WordPress edits my html?’ is closed to new replies.
