1.0.2 • Published 3 years ago

@retrohack3r/cloze v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Usage

Takes a string containing anki style cloze notation and returns an array.

const cloze = require('@retrohack3r/cloze')

/* Returns:
[ { c: 1, answer: 'answer', hint: 'hint' } ]
*/
cloze('{{c1::answer::hint}}')

/* Returns:
[
  'foo ',
  { c: 2, answer: 'bar', hint: undefined },
  ' beep ',
  { c: 1, answer: 'fizz', hint: 'buzz' },
  'boop'
]
*/
cloze('foo {{c2::bar}} beep {{c1::fizz::buzz}}boop')

The returned array contains each "chunk" of the string, where a chunk is either a plaintext string or a cloze. You can reconstruct the original string from reading the array from left to right.

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago