* ohm-grammar-quiz-markdown

A grammar for extracting Quiz structured data in JSON-LD out of markdown documents.

#+begin_src markdown
What is the correct answer?

- [ ] 41
- [x] 42
- [ ] 43
#+end_src

becomes:

#+begin_src json
{
  "@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"
        }
      ]
    }
  ]
}
#+end_src

** How To Use

Import the =parse= function from the package
and pass it a string that represents the markdown
document to parse:

#+begin_src javascript
import {parse} from '@customcommander/ohm-grammar-quiz-markdown';

parse(`
What is the correct answer?

- [ ] 41
- [x] 42
- [ ] 43
`);

#+end_src

** Limitations

1. Questions and answers *must* fit on a single line

   /Why?/

   No good reasons other than I am not very good at writing grammars.

2. 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.
