Write up your practice problem (Quiz) in Markdown and turn it into JSON-LD structured data.
Input:
What is the correct answer?
- [ ] 41
- [x] 42
- [ ] 43
Output:
{
"@context": "https://schema.org/",
"@type": "Quiz",
"hasPart": [
{
"@type": "Question",
"text": "What is the correct answer?",
"acceptedAnswer": {
"position": 1,
"@type": "Answer",
"text": "42"
},
"suggestedAnswer": [
{
"position": 0,
"@type": "Answer",
"text": "41"
},
{
"position": 2,
"@type": "Answer",
"text": "43"
}
]
}
]
}
npm i @customcommander/ohm-grammar-quiz-markdown
Import the parse
function from the package
and pass it a string that represents the markdown
document to parse:
import {parse} from '@customcommander/ohm-grammar-quiz-markdown';
parse(`
What is the correct answer?
- [ ] 41
- [x] 42
- [ ] 43
`);
- Questions and answers must fit on a single line
Why?
No good reasons other than I am not very good at writing grammars.
- Only paragraphs and lists
Why?
This is actually by design.
By restricting the syntax to the bare minimum, I hope to make documents simpler to write and read.