Markdown course to moodle book convertor

For “reasons” I was looking for a way to convert an existing markdown-course to a “moodle book” resource. (I know, I know, not really the way to go, but still…). I found this interesting python-script that exactly does this, however, it’s not very up-to-date. My Python-skills aren’t very on par, but I did manage to make it work on Python 3.7 and you can find my updated script here.

The script works nice and well and even creates nice “code fragments” and is able to import your images:

Left=markdown , Right=book in Moodle


The main drawback currently is that the needs a very strict folder structure and filenames (all files and folders have to be numbered and need to contain a file per folder).

Things you need to consider:

  • Markdown blockquotes are converted to a rather large font (which you can change of course)
  • Each chapter needs it own \book folder where the actual content will be (which will mean to you might need to rearrange your existing markdown folder structure)
  • Use the -pagetitles option if you can’t import the newly created book archive because your page titles are too long: the script will use the first header as title in your markdown, but for reasons (yet) unbeknownst to me it also used the text following the header resulting in an HTML <title> that was too long for Moodle to work with.
  • Images need to be in a subfolder of each \book folder. Meaning you can’t use one big assets folder for all your chapters (something gitbook prefers)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close