Open mkraska opened 2 years ago
To me, in markdown, both \
and (
are things that need to be escaped, so the logic I wrote requires one to use \\\(
if one wants to have STACK detect Math mode and act in the correct way. STACK does, however, note that markdown also has its HTML mode and acts in the traditional STACK way there.
So it is by design that the behaviour in 4.4 is different from 4.3? I see two ways to fix such questions:
Yes 4.3 did not support Markdown, 4.4 does but it expects one to be very clear with the syntax if one expects it to be able to detect math-mode shifts. By support, we now mean that we detect Markdown and Markdown HTML modes and math-mode shifts in them and apply escaping for injected values so that they function in those modes. All the way to the level of escaping needed for injections to function in Markdown tables. We also know not to apply Markdown escaping in places like [[jsxgraph]]
blocks that happen to exist inside Markdown content, basically, the way injections behave is now tightly tied to the surroundings and we even allow switching the injection method by switching formatting at will within the text...
Some people used Markdown with 4.3, and it probably worked as long as the injected values were trivial and/or the injection sites were carefully chosen.
This is perhaps one area where the STACK docs could be updated to make clear to authors what is expected for each of HTML and markdown. (I also suspect we need more unit tests!).
I am fairly certain that the castext2 branch had notes in the Authoring/CASText.md documentation about the rules of escaping and formats related to Markdown. Have to wonder why that file is now in master in the form it was back in 2020. In any case, it needs no more tests. The test that exists for markdown format already confirms that the escaping happens and that it goes through actual Markdown processing just as expected and that the math mode gets detected as expected.
Basically, what needs to be known by authors:
\(
the start of math-mode or is it just the escaped (
? Assuming that you declare through Moodle text-aread options or by using other means that your content is in Markdown format STACK will then figure out if some of it is in HTML mode and will escape values it injects accordingly. However, the normal way of STACK outputting \(...\)
-wrappings around {@...@}
-injections only when not in math mode already will need to be able to detect whether you are in math mode and it assumes that all the rules related to escaping are followed, and no exceptions (or relaxed rules) are in play i.e. \(
won't start a math mode in its detection logic if we are in Markdown-formatted context. Both \
and (
are special in Markdown and both need to be escaped, so if you want STACK to detect that math mode shift you need to use triple-slashes \\\(
.
Note that you do not see those extra slashes in the output, and sometimes some slashes can be omitted but they are important both for us to unambiguously detect things and for the Markdown processor to process the content after we have injected those values or expressions.
Hi, after switching to 4.4 I experience the following problem:
This is my question text. The whole question text is in Markdown format as set in the Marklar editor widget.
Possibly the
{@@}
tag makes STACK think that the entire paragraph is html instead of markdown.When explicitly tagging the line as html things get better.
I used this stuff a lot so if there is no fix I'd need to touch nearly every question in my courses (which I perhaps do anyway in order to make use of dynamic inclusion).
quiz-T-B5-MB-TM3-TM3 01 01 (l) a(t) example with units-20220803-2212.zip