Search code examples
r-markdownr-exams

[Bug/unwanted feature]: trailing whitespace and headers in r-exams


I recently started using rmarkdown and r-exams. I found that the space at the end of the word Question in this file

Question 
========
Some maths
$$
x=0
$$

Solution
========
To solve this we do more maths
$$
x=0
$$

Meta-information
================
exname: errorDemo
extype: num
exsolution: 0

That the output would show correctly when I click the knitr button in RStudio; however, when using exams2html or exams2pdf, the question text is skipped entirely.

Because the error is not visible, I imagine that it will waste my time every now and then. I wanted to check two things

  1. Is there a constructive reason why r-exams cares about trailing whitespace in these headers whereas rmarkdown does not?
  2. Is there an option that I can set to trim this whitespace from the end of headings so that I don't get the same error again? Or can select some feature so that r-exams does ignores this trailing whitespace?

Solution

  • The reason that trailing spaces were not tolerated was simply that nobody had ever run into this problem before and reported it. I've just extended the exercise parsing to support it from now on. If you install version 2.4-0 (which was still the R-Forge version when the question was asked), your minimal exercise above works as intended.