Skip to content

Write up your practice problem (Quiz) in Markdown and turn it into JSON-LD structured data.

License

Notifications You must be signed in to change notification settings

customcommander/ohm-grammar-quiz-markdown

Repository files navigation

ohm-grammar-quiz-markdown

Write up your practice problem (Quiz) in Markdown and turn it into JSON-LD structured data.

Example

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"
        }
      ]
    }
  ]
}

Install

npm i @customcommander/ohm-grammar-quiz-markdown

How To Use

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
`);

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.

About

Write up your practice problem (Quiz) in Markdown and turn it into JSON-LD structured data.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published