Updated Docs to WordPress plugin: Now with better formatting

Version 0.3-beta of our Docs to WordPress plugin has been released. It’s a fairly minor release, and only affects people using the cleaner extension, but we just rolled it out internally this morning at the BDN and it’s exciting for us, so I wanted to pass it on to the public.

The newest version of the cleaner extension passes correctly parses bold and italic text and headings, such as <h4>. It also strips out span tags to avoid a few instances where they would cause an extra line break.

In an earlier version of Docs, bold and italic text were surrounded by <em> and <strong> tags, as would be expected. It made it very easy to handle stylized text.

In the newest version of Docs, however, text formatting is done completely via CSS. So the header of each of the HTML versions of the Doc contains a stylesheet, where bold and italic text is given an arbitrary class name.

To carry that through to WordPress, I use preg_match to find the correct class name from the stylesheet and then preg_replace to convert span tags to <em> and <strong>. Thanks much to Andrew Nacin, Rob Flaherty Bill, who replied to my cry for help.

As always, the Docs to WordPress plugin can be found in the WordPress Plugin Repository.

18 thoughts on “Updated Docs to WordPress plugin: Now with better formatting”

  1. Hey there fellow journalists/techies…

    I’m the editor-in-chief for a community college paper and I’ve got to say I really love what you guys are doing. I want to get together with my online editor asap and discuss some of this stuff with her!

    I have some tech savvy, though I’m not too familiar with WP or googledocs… but our paper recently moved from collegepublisher to wordpress, and I’d love to take advantage of the transition to try out your guys’ plugins.

    Do you have docs on your guys’ workflow? I think I can implement the plug-ins but could use some guidance on how you set up your googledocs so I could try to emulate it…

    Also will the InDesign wordpress-post-browser work in a Mac OSX edition of ID?

    Thanks very much!!
    – Josh

    FYI, your e-mail link in the header of dev site seems broken.

  2. After a little fudging, I finally got this to work on my server. (Definitely my fault, not yours). I remember reading on an earlier post that you guys were further parsing files with delimited taxonomy data and wanted to know if you provide hooks or docs to handle that? We have a very specific set of taxonomy values that need to be set on a per post basis and would much rather have the contributors specify those values instead of the editors. Any insight? Thanks for your hard work on this, it’s awesome.

  3. Very interesting work… just a question :
    inDesign is able to import xml file coming from WP xmlrpc export (file or transfert).
    Why do you create taggedtext ? What is the advantages versus xml file containing full information about each post .

  4. Just wondering if the plug-in is working for you guys today (September 27). I was able to set it up last week and got it to work but now when I came in today to use, it is not showing on WordPress the posts from Google Docs. I checked the Docs account we’re using and it successfully moved the files from one collection to another. Is anyone else getting this issue?

    1. Google changed part of their API. There is a new version of the plugin available that should fix any problems.


  5. The plugin stopped working this week. But when I went in and modified it to always use https for getting docs, then it started working again. Google API must’ve changed.

  6. Been following every totally ingenious thing you’ve been doing since June, since it’s almost exactly what we need to be doing, and I finally got around to installing the plugin tonight, and . . . it doesn’t appear to be working. Is the https issue for real? I’m assuming yours is working.

    I’m not a programmer but I play one in our (very small) newspaper office. I’m guessing that wherever I found an “http” in a google docs URL in the plug-in.php file I might try replacing it with “https”? Anyway I’m embarrassed to say what a great thing you’re doing — and making most of it available to the world, too — because you’re obviously familiar with WP down to the core and I’m still burrowing slowly through the crust . . .

  7. Hi,

    First of all, let me congratulate you for this awsome work.

    I’m trying to implement your solution on a small non-profit newspaper workflow but I’m stuck in the googledocs-to-wordpress stage.

    Since there’s some comments about gDocs not working anymore in this flow, I was wondering if you could enlighten me regarding this.

    I’ve tried with 3 different sites and I’m wondering if I’m doing something wrong myself or if the plugin is really not working for now.

    Some questions:
    1. Is it usable in a multisite environment? I’ve enabled the plugin in my base site and a network site, and entered the DOCSTOWP variables in wp-config.php, and is not working in neither site. I’ve instaled it in a solo site and is not working either.

    2. The users – when you say users must have the same name in gDocs and WP, how is it possible? User in gDocs has the @gmail.com email suffix, in WP you can only have the nickname part (the ‘username’ in ‘username@gmail.com’), right? Also, the docs will only show in WP if the logged user is the same?

    3. The cron job – I read in one of your posts that the first cron.php solution is more accurate then the wp-cron.php integrated version. Is it really? One should use both?

    Thanks. Hope you can give me some light on this, I’m eager to test this all the way.

    1. Alvaro,
      Try upgrading to the newest version of the plugin and see if that solves your problems.

      The docs will show if the user is not set correctly, although the author field might not be correct. The username should be the part before the @.

      Only use either cron or the wp-cron extender. We use real cron because we want it to reliably be pulled over within the minute. It will definitely get pulled over using wp-cron, it might just take more than a minute.


  8. Hello,
    I was wondering copying text from Google docs and pasting into WordPress / Dreamweaver shows that there is a tag around all text. The result is everything is in bold.

    I guess that is how Google Docs works , no way to copy the code from google docs without the strong tag.

    example of text copied from google docs documents. =

    This document is an agreement between Employers, Contractors and Fixxi.net for services delivery on taking place on Fixxi.net.

    It is designed to provide fairness and win-win in remote service delivery.

    1. Steve,
      Are you using the Docs to WordPress plugin? This sounds like an issue with the text editor, not my plugin.

  9. First, a quick thank you for a great plugin. I’ve been on a quest for better integration with Google Docs and this is a GREAT direction you’ve taken!

    After realizing I needed to activate cURL on my XAMPP localhost WP installation, everything started working nicely.

    I do have one question:

    If I create or drag a GDoc, into the defined ‘DOCSTOWP_ORIGIN’ collection (i.e. “Docs-Draft”), with the CRON ext. activated, it shows up almost instantly as a draft WP post. Very good.

    However, if I edit or make changes to what is now a WP post using the WP editor, these changes do not seem to upload to the source GDoc. However, if I make updates to the GDoc source, the corresponding WP Post content is overwritten. Is this by design?

    Put another way, can we only do one way sync with changes only made to the source GDoc for everything to stay in sync?

    As an aside, although I also created a “Published” GDoc collection and defined it in wp-config.php, I’ve commented out the ‘DOCSTOWP_DESTINATION’ line for now because any changes made from within WP, whether saved as draft or published, seems to auto relocate to the Published collection, whether I like it or not.

    Perhaps I’m just not clear on the recommended process flow to maximize the benefits of this great plugin. Do you have one written explaining how your organization does things to maximum benefit for all?

    Thanks again for a great effort!


    1. Lars,
      Right now the plugin only supports syncing from Google Docs to WordPress, not from WordPress to Google Docs. The reason for this limitation is that the Google Docs API really has no support that I can find for complex changes to docs — you would pretty much lose everything except the text, including links and comments.

      I’m not sure I understand your second question. Can you explain it a bit more, but what’s happening now and the expected behavior?

  10. Thanks for the quick reply William.

    As for GDoc API and syncing, I’m no coding expert but I love reverse engineering 😉
    I might suggest you take a look at the Google Chrome ext. “Scratchpad – A simple note-taking app. Take notes offline and optionally syncs to the cloud when you’re online.”

    Not sure how the developer coded it but he seems to have cracked the nut on writing offline and syncing with GDoc (both ways).

    Where it gets fun is all notes created using the ext. are uploaded to the GDoc collection “Scratchpad”. Leveraging your plugin, I set this collection as the “DOCSTOWP_ORIGIN”. Now, everything is added as “draft” posts to my local WP installation. For edits and updates, I’ll make them in either GDoc or “Scratchpad” yet have them readily available for viewing on my WP Authoring/CRM Dashboard. I’d attach a visual to better explain but I can’t seem to find a way to do so here.

    As for the second question, I’m just not clear what triggers your plugin to move referenced GDocs from the ORIGIN collection to the DESTINATION collection. When a destination collection is assgined in the wp-config.php file, it seems to move GDocs ANYTIME changes to the WP created post are made and not just when I Publish from Draft (e.g. assigning category, adding tags, etc.). Is there a way to configure to keep things as they are and only move when WP Draft posts are Published?

    The second part of the question was really more a request for a “cheat sheet” on how you and your team use the plugin. e.g. a process flow list of steps from post idea to collaboration to publication. You touch on it at the beginning of this post I guess I’m just hoping for a little more detail.

    All the best,


Leave a Reply

Your email address will not be published. Required fields are marked *