STACK: add line numbers/ highlight to Question and Feedback variables#1790
STACK: add line numbers/ highlight to Question and Feedback variables#1790vuvanhieu143 wants to merge 2 commits into
Conversation
|
Thanks @vuvanhieu143 that's really very helpful indeed. This has been on our wishlist for sometime, and I'm very grateful to you for sorting this out. For sure, we can improve the support for Maxima syntax. I've changed the base to "dev" so this can be staged for the next release. This is timely as we just released a new version (4.13.0) and are agreeing priorities for development for the next cycle. This feature was on the list. We'll review, test and I hope accept this. |
|
There is a VS Code extension that does a great job of highlighting Maxima's syntax. Perhaps some of this extension's highlighting rules could also be useful here for making Maxima easier to read. |
EJMFarrow
left a comment
There was a problem hiding this comment.
Hi, @vuvanhieu143 . Thanks so much for this. Looks very useful. I think it needs a little tidying up before merging.
| @@ -217,6 +218,13 @@ protected function definition() { | |||
| if ($closebeforebuttonarr !== false) { | |||
| unset($mform->defaultRenderer()->_stopFieldsetElements[$closebeforebuttonarr]); | |||
| } | |||
| // Disable ace editor when running behat. | |||
| if (!defined('BEHAT_SITE_RUNNING')) { | |||
There was a problem hiding this comment.
This requires more explanation but it would be better if the editor was not disabled when running Behat.
There was a problem hiding this comment.
Hi @EJMFarrow , The reason I disabled it for Behat is that the existing Behat tests can't be reused when the Ace Editor is rendered, unless we update the tests with custom Behat steps or use CSS-based workarounds.
Since we can't meaningfully test the Ace Editor itself with Behat, I don't think there's much value in enabling it during Behat runs.
Does that make sense?
|
hanks for the suggestions, @Mat-Ge. I've updated the Maxima syntax highlighting rules and added unit tests to cover the changes. @EJMFarrow, I've switched the implementation to use RequireJS and removed the unrelated JavaScript files that were no longer needed. I've also explained why I chose not to render the Ace Editor when running Behat tests. |
Hi @sangwinc ,
As Chris Nelson mentioned in his email, we're looking to add line numbers and syntax highlighting for STACK questions.
I've implemented this using the Ace Editor library: https://ace.c9.io/#nav=higlighter
Since Ace doesn't provide syntax highlighting for STACK/Maxima out of the box, I wrote a custom highlighting mode for it. I'm not familiar with every aspect of the STACK language, so my implementation may not cover all cases. If you notice anything that could be improved or any syntax that isn't highlighted correctly, please let me know and I'll update the rules.
This is what the new UI looks like. At the moment, I've only enabled it for the Question variables and Feedback variables fields. The feature is enabled by default, but if we'd prefer to make it optional, I can add an admin setting to turn it on or off.