Problem/Motivation
The usual way of managing text parsing in Drupal is through text formats, which are collections of input filters. That MathJax adds a 'global' filter – set by path/page rather than the selected text format – may confuse Drupal users (and deviates from best practices). It also risks parsing text as LaTeX, when the user had no intention of writing LaTeX.
Proposed resolution
* Add a filter for MathJax, that can be used when setting up text formats.
* Allow using this filter, as an alternative to the 'global switch'.
Completed tasks
* Added a MathJax text-filter.
* Removed deprecated configuration variables.
* Removed the per-page activation settings.
* Modify the administration forms with a radio button choice for configuration: text format, or custom.
* Retain the current configuration as "custom" when upgrading.
* Load the appropriate configuration based on the user's choice.
* Text format will be the default for new installs.
* Functional testing.
* Web tests.
Remaining tasks
User interface changes
* A new filter at the text formats settings.
* A choice of configuration types: global, text format, or custom.
* Custom will be the default when upgrading.
API changes
Not applicable.
Related Issues
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 2084267-7.patch | 376 bytes | jweinstein |
Comments
Comment #1
cilefen commentedThis is a much-needed feature.
Comment #2
cilefen commentedUnder Remaining Tasks, I also suggest we add: Read up on how to apply MathJax formatting to certain DOM elements (not globally).
Comment #3
cilefen commentedExample module that creates an input filter.
Comment #4
cilefen commentedI pushed a prototype to 7.x-2.x.
To test it, set up an input type with the MathJax filter and also set your MathJax configuration to:
Known issues:
* This will work on only one DOM ID. This is because the Typeset() method by default wants a DOM ID, not a class.
Comment #5
cilefen commentedSee issue #2084267: Allow using MathJax as a input filter for text formats, rather than a global filter
This is a prototype of the idea. To test it, set up an input type with the MathJax filter and also set your MathJax configuration to:
Known issues:
* None
Comment #6
cilefen commentedThis was done with the advice of Peter Krautzberger on the MathJax user group: https://groups.google.com/d/topic/mathjax-users/kGLtdrssYrg/discussion
Comment #7
jweinstein commentedThe filter works as expected - with the patch attached, save the default MathJax configuration and create a text format using a MathJax filter.
The patch adds a missing comma to the MathJax configuration variable.
Comment #8
cilefen commentedThank you - patched.
Comment #9
itangalo commentedAwesome work on this feature!
However, as far as I can tell the patch doesn't make much difference. I still need to enable MathJax globally, and then everything on a page will be processed – regardless of whether the filter is used or not. (This is at least what happens when I try the 2.x branch on a node with plain text filter. Even the title is processed by MathJax.)
I'll dig a bit, and see what I can find.
Comment #10
cilefen commentedDid you replace the MathJax configuration on the admin screen with this?:
Comment #11
itangalo commentedThat's probably what I did wrong – now things are working as they should. Thanks!
Comment #12
itangalo commentedI also realized that the MathJax filter needs to be placed below the 'Limit allowed HTML tags' filter. Not 100% why.
Comment #13
itangalo commentedAgain – awesome stuff. I was going to sit down and try to write this code tonight, and found that it was already written! (Instead I could spend some time on boring code cleanup, to spare you that work.)
Are you thinking of keeping the 'global' option for MathJax in the 2.x branch? If so, that checkbox on the config page makes sense – but then the conditions for running input filters must be reversed (and only used if the global switch is off).
If the global option will be dropped, then the condition for running input filters can be dropped all together. (If the filter is called, it should always be executed.)
Comment #14
cilefen commentedLet me think about that a while.
Comment #15
cilefen commentedI think we need to either throw away the global option or offer a choice:
(*) Text filter: MathJax will be available as a text filter.
( ) MathJax runs globally.
By choosing either option, a default MathJax configuration will be placed into the admin form (by JS, I think), then the admin may edit.
Comment #16
cilefen commentedComment #17
cilefen commentedComment #18
cilefen commentedComment #19
cilefen commentedComment #20
cilefen commentedComment #21
cilefen commented7.x-2.0 beta
Comment #22
jweinstein commentedAfter testing the 7.x-2.x branch, using mathjax as a text format seems to work. The instructions are clear and work as expected.
Comment #23
cilefen commentedAutomated tests were failing in 7.x-2.x-beta1, those have been fixed in 7.x-2.x.
Comment #24
cilefen commentedComment #25
cilefen commented