Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Converting markdown MCQs to Betterquiz BQF format

Converting markdown MCQs to Betterquiz BQF format

Betterquiz is a format and engine for creating multiple-choice tests and embedding them on websites in an iframe. It’s an open-source project hosted here.

For Bettercare, we create MCQ quizzes for books in kramdown-flavoured markdown. We then need to quickly convert them to BQF for uploading to our Betterquiz server.

This series of regex search-and-replaces turns a kramdown quiz file into a BQF file. In each case, the first line is the search, and the second line the replace (unless you should replace with nothing).

  1. Remove numbers from questions.

    Find (and replace with an empty line) lines starting with a number between 1 and 99, a dot, and a tab (regex background):

  2. Remove the tab before bullet characters and +:

  3. Remove YAML book: and add the title text only to title (note the space after :):

    book: (.*)\r\ntitle: 
    title: \1\.
  4. Remove # heading, by replacing this with nothing:

    \r\n# Test(.*)\r\n
  5. Remove layout YAML, if any, by replacing this with nothing:

    \r\nlayout: (.*)
  6. Remove -s around YAML frontmatter, by replacing this with nothing:

  7. Remove markdown emphasis and strong elements with a non-regex search and replace to remove *.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.