Implement Symbol "Corners" (before/after super/subscripts)
Drasil deals with two categories of "symbols:" code symbols (i.e., variables) and math symbols (as we see on pen and paper). Symbols are constructed with the Symbol data type:
https://github.com/JacquesCarette/Drasil/blob/390cd3276819387a10b9313853c96a3172c82281/code/drasil-lang/lib/Language/Drasil/Symbol.hs#L26-L64
The goal is to implement symbol "corners" (pre/post sub/superscripts). For example, ${}^s_s{s}^s_s$, where each $s$ is any other Symbol, is a symbol with sub-symbols at each "corner." The goal for this ticket is to implement this in Drasil correctly.
Drasil has an existing implementation: https://github.com/JacquesCarette/Drasil/blob/390cd3276819387a10b9313853c96a3172c82281/code/drasil-lang/lib/Language/Drasil/Symbol.hs#L51-L61
However, it has at least one issue with rendering post sub/superscripts when both a subscript and a superscript are appended to the symbol (#3188). Furthermore, all prefixed corners are unsupported: https://github.com/JacquesCarette/Drasil/blob/390cd3276819387a10b9313853c96a3172c82281/code/drasil-printers/lib/Language/Drasil/Printing/Import/Symbol.hs#L21-L26
I've already made an attempt in #4034 where you can learn about some of the issues I faced when I tried to implement this. I will also attach the git .patch for your reference (4034.patch).
Original Issue Description:
The title to this issue is fairly vague, and that's because I'm not certain I understand the intricacies of what needs to be done. I do know that this is an issue.
Symbols defines a constructor Corners which allows the user to add arbitrary super/subscripts to any of the corners of an inner symbol.
https://github.com/JacquesCarette/Drasil/blob/76913ecbd3ef11258b38294318fdfb6d81502585/code/drasil-lang/Language/Drasil/Symbol.hs#L27
The issue arises that the common smart constructors always wrap an existing symbol with a new instance of corners:
https://github.com/JacquesCarette/Drasil/blob/76913ecbd3ef11258b38294318fdfb6d81502585/code/drasil-lang/Language/Drasil/Symbol.hs#L130-L143
Moreover, symbol rendering can only handle top right and bottom right corner rendering individually in both the HTML and LaTeX printers. Want to use a combination or something else? You're SOL at the moment.
LaTeX: https://github.com/JacquesCarette/Drasil/blob/76913ecbd3ef11258b38294318fdfb6d81502585/code/drasil-printers/Language/Drasil/TeX/Print.hs#L82-L86
HTML: https://github.com/JacquesCarette/Drasil/blob/76913ecbd3ef11258b38294318fdfb6d81502585/code/drasil-printers/Language/Drasil/HTML/Print.hs#L119-L123
Fun fact: Now that I see the HTML super and subscript renderer code, it can render nested Corners cases incorrectly and is inconsistent in behaviour with the LaTeX printer.
So really, this comes down to the fact that I think Corners as an idea needs to be better understood.
- What do items in different corners mean?
- Can multiple corners be populated at the same nesting "level"?
- Should the way
Cornersis represented have some sort of precedence where nestedCorners"resets" precedence similar to brackets? - Visually how do you represent (and understand) nested and multiple corners?
Yeah, these definitely are bugs. This needs a proper design.
To my knowledge, 'prescripts' are written in LaTeX (and similarly in KaTeX) using a null text placed before the 'middle' symbol. For example, ${}^1_2a^3_4$ is written with ${}^1_2a^3_4$ (edit my comment to have a peek!). Adding this might however create issue with nearby symbols (which is another issue on its own!).