cognitive-engineering-lab / mdbook-quiz

Interactive quizzes for Markdown
http://cel.cs.brown.edu/mdbook-quiz/
Apache License 2.0
99 stars 21 forks source link

Option to turn off spelling check (+log line to confirm preprocessor is active) #39

Closed bartvanderwal closed 8 months ago

bartvanderwal commented 10 months ago
  1. I'm writing a mdbook-quiz in Dutch. Upon building the mdbook I get errors in spelling. I see that I can add a custom .dic, but for now I'd prefer to switch this off. Is there a setting for the book.toml like for instance spelling-check = false which I can add below the [preprocessor.quiz]?

  2. Another issue is that the quiz question block is NOT shown at all in the rendered website. But that could be due to some custom styling or something. I AM missing a short log line like from the quiz preprocessor starting in the pipeline, which OTHER mdbook preprocessors, like the mdbook-linkcheck DOo emit.

In the end inally I found that there is a placeholder

in the DOM of the page, which however is not shown due to .mjs error (shown in JS console). But a log message would have saved me some time and doubt. See screenshot below for some visuals for these two suggestions/questions 😅 .

image
bartvanderwal commented 10 months ago

Ok, note to self: If I have time I'll try to fix above errors (though I have never programmed in Rust before).

I'm using mdbook in education, and basically having correct spelling is a nice way of 'Eating your own dogfood'. Especially for spelling picky people like myself. But now that I DID add a .dic file as a work around for the spelling warnings on build I do get other issues:

failed to build dictionary!: Parse(ParseError { err: DictEntry, span: Some(Span { start: LineCol { line: 162968, col: 0 }, end: LineCol { line: 162969, col: 0 } }), ctx: "jacuzzi/Zc\tOpmerking: Jacuzzi® is een geregistreerd merk van Jacuzzi Inc, USA" })

And after simply removing this fluke 'jacuzzi' entry in my .dic file I get another failed to build dictionary error I can't find a workaround for:

2023-11-03 07:39:37 [INFO] (mdbook::book): Book building has started
thread '<unnamed>' panicked at /Users/my-name/.cargo/registry/src/index.crates.io-6f17d22bba15001f/mdbook-quiz-validate-0.2.0/src/spellcheck.rs:31:8:
failed to build dictionary!: Parse(ParseError { err: MorphInfoDelim("Rica"), span: Some(Span { start: LineCol { line: 196203, col: 0 }, end: LineCol { line: 196204, col: 0 } }), ctx: "Rica" })
stack backtrace:
   0: rust_begin_unwind
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
   1: core::panicking::panic_fmt
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/result.rs:1652:5
   3: std::sync::once::Once::call_once_force::{{closure}}
   4: std::sys_common::once::queue::Once::call
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/once/queue.rs:183:21
   5: std::sync::once_lock::OnceLock<T>::initialize
   6: mdbook_quiz_validate::impls::markdown::<impl mdbook_quiz_validate::Validate for mdbook_quiz_schema::Markdown>::validate
   7: mdbook_quiz_validate::impls::multiple_choice::<impl mdbook_quiz_validate::Validate for mdbook_quiz_schema::MultipleChoicePrompt>::validate

Here is the .dic file I used for possible debugging (I could NOT upload to this issue with a .dic extensions so I added .txt. dutch.dic.txt

Do you have a simple example .dic file that works for you?

willcrichton commented 10 months ago

Thank you for the feedback!

  • I added a log line to indicate when the preprocessor is running.
  • I made spell-checking optional. Now you can add spellcheck = true to the config file to enable it.
  • I added some documentation for how to find/write .dic files. You can find a base dictionary here, and you can find the .dic format documented here.

I will release these changes in a new version once all of your issues have been fixed.

Now you said the quizzes aren't loading when you open the page? Can you paste the Javascript error you're observing?

willcrichton commented 8 months ago

Btw all the spelling changes were released in v0.3.4. Please reopen this issue if you still have any problems.