Skip to content

Instantly share code, notes, and snippets.

@leggetter
Last active December 22, 2015 10:18
Show Gist options
  • Save leggetter/6457525 to your computer and use it in GitHub Desktop.
Save leggetter/6457525 to your computer and use it in GitHub Desktop.
We have a number of entries in a Confluence wiki that we'd like to migrate to a github wiki. However, Confluence seems to have it's own Wiki Markup. I'd love to create an automated process for the migration, but for the moment these manual steps help.

Migrate Confluence Wiki Markup to Github Markdown

Get the Confluence Wiki Markup

Go to the page and click "Edit". The "View wiki markup" option removes whitespace.

Paste that into your favourite text editor.

Converting inline code

{{var something = "fish";}}

becomes

`something`

Converting block code

{code}
var something = "fish";
var cheese = "monkey";
{code}

becomes

```
var something = "fish";
var cheese = "monkey";
```

or (indent each line four spaces)

    var something = "fish";
    var cheese = "monkey";

Convert header tags

Convert header tags to headers prefixed with # where the number of #'s should be the same as the header level e.g.

h1. Fish

becomes

# Fish

and

h4. Monkey

becomes

#### Monkey

Converting Lists

Markdown lists are the same for single level lists e.g.

* item 1
* item 2
* item ...

However, they differ when creating nested lists. The solution is to replace the number of asterisks (s) with (s * 2) - 2 spaces, then the asterisk and another space before the content e.g.

* top
** level 2
*** level 3
**** level 4
***** level 5

* top
  * level 2 (2 spaces) 
    * level 3 (4 spaces)
      * level 4 (6 spaces)
        * level 5 (8 spaces)

You get the idea, right?

Image attachments

Unfortunately github doesn't presently have a great solution for this. However, since github wikis are just repos you can add images to the repo and then reference them.

Clone a github wiki

The git URL for the wiki for your repo is very similar to the one for your actual repo. In fact, it just has a .wiki before the trailing .git e.g.

git@github.com:BladeRunnerJS/brjs.git

becomes

git@github.com:BladeRunnerJS/brjs.wiki.git

So, you can clone the wiki repo as normal:

git clone git@github.com:BladeRunnerJS/brjs.wiki.git
cd brjs.wiki

And then add any images you want e.g.

mkdir img
cp path/to/some/images/* img/

Then add, commit and push

git add img
git commit -m 'some commit message'
git push origin master

You can now reference the images via the relative path from the wiki document you are editing e.g. if I were editing the standard Home.md I could now reference an image named example.png in the new img directory as follows:

# Wiki Home Page

[[img/example.png]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment