Word as end-use is a very strange topic for me to blog about, but I just discovered a tip that would have saved me countless hours of time. So I thought to share it.

At the moment I’m writing a book (yeah, another one): for my personal convenience I write it in Markdown, so that I can easily push it to GitHub, and work on it from different devices and even when travelling via tablet.

I’ve synced my private repository to Gitbook so that I can easily read it online or export it to PDF or Word, but unfortunately I cannot rely on these features to send the chapters to my publisher. In fact book publishers have very strict rules when it comes to styles in Word documents. For example, if I want a bullet list, I cannot just click the bullet list button button in the toolbar, but I’ve to apply a “bulletlist” style. Same goes for all the other standard styles.

For most of the styles it’s not a big deal: I just select the lines I need to re-style and in 15-20 minutes a 20 pages chapter is formatted.

The problem arrives when formatting “inline code”: in markdown, inline code is formatted with back-ticks (`), so each time I need to show something as inline I’ve to remove the the trailing and leading ticks, and then apply the “inlinecode” Word style. This process alone, in a typical chapter, takes away at least a few hours of time. After a few chapters and hours of frustration I asked for help to my girlfriend, whom, working in language translation, uses Word as her main working tool all day: she had a solution for this problem, so I’m sharing it in case other fellow technical writers need it.

First open the Advanced Find dialog, switch to the Replace tab:

  • In Find you put a kind simplified regular expression: (`)(*)(`). This means: find any sting which starts with a back-tick, and ends with a back-tick.
  • In Replace put \2. This means: replace it with the content of the second “match group”. Also specify the style you want applied, in my case “InlineCode”.
  • And remember to check the box Use wildcards, otherwise this won’t work.

Let’s see in action on some lines from my upcoming book with the markdown file:

markdown

Once pasted into Word (and applied the basic styling) it becomes (notice all that text with back-ticks):

word

I then apply the magic find&replace:

find

And voila! In a few seconds 20 pages of Word documents are correctly updated by removing the ticks around inline code and applying the correct style.

Post

it’s not my typical content, but I hope you’ve learnt some thing that you didn’t know.

To see all you can do with wildcards: How to Use Wildcards When Searching in Word 2013

Next step in automating this process would be writing some code that automatically formats it properly in one go.