The pain with sourcecode in WordPress

I don’t know why, but I always felt better when I prepared my blog posts somewhere else (Google Docs in my case) and then just pasted them to I wanted some backup – but there is WordPress feature for that. But the most important factor was their editor. It was able to mess up with the post in a one-way way (when undo doesn’t help), so I just refused to use it in the first place. Google has versioning, reliable undo, auto-saves often, etc.

The biggest issue was always related to posting source code examples. In “good old” WordPress editor I had some workflow that worked well enough when I was pasting code from Google Docs, I had to go through it and fix some details, but it was usable.

And then their new editor (Beep beep boop) came. What was easy before became nearly impossible now. Not to be all negative, normal formatted text can be easily copied/pasted from Google Doc to WordPress, so I don’t have to care about hyperlinks and formatting anymore. But the source code – that had its issues before – got virtually “unpastable”. At least not directly.

With old editor I often just started in HTML view, pasted the plaintext there and formatted headers and bolds and links in Visual mode. Annoying, but working. But we will not discuss this scenario, because that requires a lot of work after the paste. We will focus on the Visual mode of new editor – how unreliable that one is when you want to just copy/paste something in it. After all, I expected that more will work with new editor – but it didn’t deliver.

Basic workflow

It’s pretty easy. I open the WordPress editor, paste the post title and then paste the whole post in Visual mode. At the bottom of it I have my tags for the post. Tags are just another new stupid issue with the new editor, but it doesn’t kill so much time as source code does. I use sources a lot in my posts, it’s my line of work after all.

So after the whole post is there, it’s time to go over all the sources and fix them one by one. Well, let’s see what happens when you paste code from Google Doc directly:

copy-paste-source-from-googledocYou can paste with Ctrl+V or Ctrl+Shift+V – but the latter is not useful when you need formatting in your post – and you always do. Ctrl+Shift+V would be useful during fixing the codes one by one, but it doesn’t work when you do it directly from Google Doc anyway. It just screws them in different manner.

Spoiler: You can copy/paste directly in HTML mode. But we will stay in Visual mode for a bit longer and introduce more of its annoyances.

Copy/paste inside the post breaks it too!

Ok, this really got me. Maybe we can have some understanding when some editor doesn’t accept pasted stuff from different product – but this one cannot even accept its own stuff. I wanted to rewrite “tags” to in order to get syntax highlighting. Let’s see how that went:

copy-paste-demages-sourcesWhich leads us to another problem – undo. It completely breaks sources that were OK before. And not just the one that is around, but also others:

undo-damages-other-sourcesThis renders undo as extremely unreliable feature. There is no way to undo this mess after it happened. You have to fix it manually or reload the page to get the last working draft (if you made some changes – your fault). It will tell you about newer version and asks you to restore it, which you – of course – don’t want now. To get rid of this, click on Save Draft (after that reload). Trash probably removes the whole post I guess, so there is no way to discard current changes.

Any way to copy stuff?

As I mentioned, you can try it in HTML mode if it is what leads to success – and in case of it seems to be working solution. But how about in Visual mode? If you copy/paste things a lot – funny I do, because I fight copy/paste coding mercilessly – you might have noticed that often the source program kinda affects how the things are pasted. In this case it results in mess whether you use Ctrl+V or the same with Shift added (normally works as copy without format, not sure what it suppose to do in Beep-beep-poo editor though).

But what if we drag the text through something that makes it plain text? So I tried to paste it into a notepad first (Notepad2 here, but it doesn’t make a difference) and then copy it from there:

paste-via-notepadA bit longer “video”, again this is not without its twist. We have to Ctrl+Shift+V from plain text editor, otherwise the pasted text contains nbsp… which may be harmless (haven’t tried), but I simply don’t want it there. I expect some “canonical” representation of what I work on in my editor, not low level HTML stuff.

Undo is documented again – after simple paste only the pasted code is messed, after Undo other codes are affected too.


This again seems like win of Web 2.0 over reason. Before I could just copy/paste all my tags separated with a comma – at once. Not anymore. If you do so they will all form one giant tag. You simply have to write (or paste) them one by one. While writing, comma works as a separator and it instantly ends the word and makes it a tag bubble. But goodbye to “batch” copy/paste.

Final words

The biggest trouble is how brittle it all is. How easy it is to damage all the nicely formatted source code with a single Undo. Would you seriously consider writing in such an editor? I merely tip-toe around it, paste my post, fix the mess and Publish as soon as I can. It is possible to Edit simple typos later. But anything beyond that…? Well my trust is not there.

If WordPress developers ever change the editor again, I hope they will go for usability that actually involves copy/paste as well. I don’t know, maybe I’m such a weirdo and “lucky” to find all these corner-cases (it’s not only WordPress after all) – maybe I’d be great tester. But I seriously don’t think I’m pushing everything to some limits or so.

After all – I just copy/pasted in this case! 🙂

BTW: My previous post was copy/pasted to Visual editor to preserve all the formatting and links, and then I switched to HTML where I easily copied all the code (one by one). Seems to be my workflow of choice for some time. Visual editor and code simply don’t go together.


Blogging for two years!

Yeah, it’s true! I would probably not celebrate it if I had ended my blogger’s career in a typical way (you guessed it… I meant simply to stop writing). It was actually pretty close to that but I somehow revived my taste to write again. The taste I have since my early years as I always liked to write various short stories. The biggest of them is my Slovak mini-novel called Cesta (The Way or maybe The Journey, doesn’t really matter) and as it is the biggest thing I really pulled off to the end it’s no surprise I decided to revive and revise it as well.

But originally this blog was created because of Utopia. I’d had my utopia in my head for some time before but I simply did not write that time. I generally still write much less than I used to. I used to write songs as well, now it’s more than four years since my last one. Satisfied comfy life might be the creativity killer. But I did other things! I made some maps for UT2004, I started the promising page about UT3 level editing (still has many visits every day mostly thanks to static mesh catalogue) and if there had not been some troubles with UT3 and/or my online connectivity problems I would have continued in these areas. And I still may in the future as the desire to do some map returns to me here and there.

But back to the blog itself. I expected Gavin to meet his Susan in just a few installments of the Utopia, but discussions were longer than I expected and I didn’t want to have posts too long. We’re obviously far from any end with Utopia – I don’t have any in my head actually because it’s the Utopia exploration in the first place. 🙂 Cesta is my sure shot – I can release any part anytime if I find just a little time to reread and correct it. But aside from these things I knew from the start that I want to write about current things around me as well. It wasn’t any accident that I started to write about Google, now I use Google Docs to write and “backup” my posts, I originally started on Blogspot until I found out that there were serious problem with printing from that page and that these problems were unsolved for a few years (I don’t care about current situation).

As said in “About me and this Blog” this site is not really topical, but while I agree that it’s nice to have a topical blogs, I think it’s not the problem to do otherwise as well. There are many post aggregators that feed various topical lists with appropriately tagged posts. So Java people have their posts from my site and people interested in music or movies have their too. There are search engines after all. While my post about Seam haven’t attracted any attention, other two Java posts related to some very specific problems with specific products and setups have been read and I’m sure they will be. Doesn’t matter that they are maybe the most off-topic if there is any topic on this blog. 😉

After some initial enthusiasm (13 posts in last 80 days of 2006) I had obvious crisis during the whole year of 2007 (only 7 posts!). Notice the big gap between May and November – ended with Travian Intermezzo – yup, Travian is killing the rest of your life. 🙂 Year 2008 started much better. I have moved here to WordPress, I helped my wife to establish her blog about cooking (in Slovak, but with a lot of pictures :-P), I started to write about games and other stuff (music, movies, although I have to extend this part ;-)) and I started to be active blogger again!

After those two years I’m happy to be here although my blog is more loose than I expected. I don’t care. I have some visitors (although my wife’s cooking blog is beating me even without using world language!), I have something to look back to – and I believe I have also a lot of to look forward to. And I want to thank you for bearing with me. 🙂

Moving In

This is actually copy of post from Blogspot after I migrated all posts here. Only the title there is “Moving Out”. 🙂

When my wife wanted to create blog with recipes I suggested Blogspot because I liked it and it was Google corporate. I like Google products. But Blogspot is first case when I decided to move out. Continuation of this blog can be found here:

Now – of course – it’s time to explain why. Well, the reason is very silly. 😉 It’s impossible to print properly blog posts from here without some effort. I don’t care about my blog – but recipes are likely to be printed out. In Firefox you get first page nearly empty (only title) and second contains your post – but only what fits there. Anything else is not printed at all. Not to mention that sidebar is standing in the way narrowing print area. IE works a bit better but there are reported problems with it as well.

You can probably solve this with some custom styles, but whatever I tried it didn’t work for me. HTML template consists of various blogger tags and I can’t limit default style to be media=screen only which makes my media=print style to be effectively ignored. This makes a lot of advices (to be found in various Blogspot posts) from 2005 invalid because they worked with more plain HTML template.

Long story short: There is no easy solution to print and I decided not to continue on blog site that works in this status for at least three years now.

I work with many SW products and normally I just address authors and tell them. However Blogger is for free and I can’t expect fix very soon when it’s like this for many years. To contact Google (I mean normal written text) is not that easy because all those forms lead you in circles to various helps – which obviously can’t help me now. And Blogger Google Group? You can find the same problem there – unsolved. I tried different layouts – that’s also why I don’t have my previous style anymore (and I don’t plan to change it back because it’s pointless now).

I’m staying with Google – but I’m leaving Blogspot. I’ll leave this blog here and maybe sometimes I post here just a summary pointing out to my new blog. But I’m blogging elsewhere now. So does my wife with her recipes (Slovak language). 🙂

Final note: Of course here I have to pay $15 per year for custom CSS, but even without that it:
* works in the first place (whole post is printed);
* side bar is printed after the article, so you can just set last page(s) not to be printed.