Skip to content

Conversation

@lionelvoirol
Copy link

Hi,

Currently, the fct longmcq() do not support math expression when used in a quarto website.

Indeed, consider for example the following choices:

 opts <- c(
     "\\(\\frac{1}{10}\\)",
     "\\(\\frac{3}{10}\\)",
     "\\(\\frac{2}{5}\\)",
     answer =     "\\( \\frac{52}{100}\\)"
 )

Running longmcq() on that vector returns:

> longmcq(opts)
[1] "<div class='webex-radiogroup' id='radio_XEJMHGSWZF'><label><input type=\"radio\" autocomplete=\"off\" name=\"radio_XEJMHGSWZF\" value=\"\"></input> <span>\\(\\frac{1}{10}\\)</span></label><label><input type=\"radio\" autocomplete=\"off\" name=\"radio_XEJMHGSWZF\" value=\"\"></input> <span>\\(\\frac{3}{10}\\)</span></label><label><input type=\"radio\" autocomplete=\"off\" name=\"radio_XEJMHGSWZF\" value=\"\"></input> <span>\\(\\frac{2}{5}\\)</span></label><label><input type=\"radio\" autocomplete=\"off\" name=\"radio_XEJMHGSWZF\" value=\"answer\"></input> <span>\\( \\frac{52}{100}\\)</span></label></div>\n"

However, when using cat() on that object, you will get:

> cat(longmcq(opts))
<div class='webex-radiogroup' id='radio_XRQNLWVXID'><label><input type="radio" autocomplete="off" name="radio_XRQNLWVXID" value=""></input> <span>\(\frac{1}{10}\)</span></label><label><input type="radio" autocomplete="off" name="radio_XRQNLWVXID" value=""></input> <span>\(\frac{3}{10}\)</span></label><label><input type="radio" autocomplete="off" name="radio_XRQNLWVXID" value=""></input> <span>\(\frac{2}{5}\)</span></label><label><input type="radio" autocomplete="off" name="radio_XRQNLWVXID" value="answer"></input> <span>\( \frac{52}{100}\)</span></label></div>

and so this will not render correctly in your quarto website using mathjax or katex.

This PR fix this by adding backslashes when these escapes characters are recognized and allowing to use longmcq() and printing its content using cat() and correctly rendering math expression in a quarto website.

See an example at : https://intro-statistique.netlify.app

Best

…hen content is printed using cat in a quatro website
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant