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).
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):
Remove the tab before bullet characters
book:and add the title text only to
title(note the space after
book: (.*)\r\ntitle: title: \1\.
#heading, by replacing this with nothing:
Remove layout YAML, if any, by replacing this with nothing:
-s around YAML frontmatter, by replacing this with nothing:
Remove markdown emphasis and strong elements with a non-regex search and replace to remove