Plugin Author
pepe
(@pputzer)
It’s probably not the answer you are looking for, but have you tried using the MathML variant of the MathJax syntax? That should work out of the box. I’ll look into a way to filter those out, but I fear that the $
sign as a delimiter is not specific enough for longer phrases. \( ... \)
are uncommon enough. Maybe a separate compatibility filter that removes inserted ­
etc. Mhm.
MathML is not an option, I’m afraid.
I am actually using a custom solution for LaTeX. Before MathJax parses the page, I can run a separate JS which would filter the ­ guys out. Probably will use this solution for now.
Plugin Author
pepe
(@pputzer)
And you do want hyphenation for the rest of the document, I assume?
Yes.
Anyway, I’ve tried the JS filtering solution, and in principle it could work, but it seems to overcomplicate matters. Rather, I would do this at PHP level.
One idea that I had was to use RegEx instead of actually creating a parser. In fact, I was able to cook up a JS RegEx that captured all $…$ groups skipping over \$ (\$ is used where I actually want the dollar sign to appear).
At PHP level, if this RegEx is used, it is straightforward to wrap all of these $…$ groups in a <span> with some class. But this must run before ­ is inserted. So, I would appreciate it if you made this as an option in the plugin.
Let me know what you think.
Plugin Author
pepe
(@pputzer)
In theory, it should be enough to run a filter on the_content
with a priority of less than 9999 (i.e. the default priority of 10 should be fine). This will only catch wp-Typography running on the post content, though, not titles etc. I might need to add additional hooks for a more generic solution.
Plugin Author
pepe
(@pputzer)
@firelord: Can you post your JS regex here? Is it just for $...$
or do you use other delimiters as well?
Right now I have the PHP version at hand: (?<!\\)\$((?:\\[^\n\r\x{2028}\x{2029}]|[^$])*)(?<!\\)\$
Didn’t extensively test it.
Plugin Author
pepe
(@pputzer)
@firelord To revisit this topic – do you only have issues with ­
/hyphenation or are other typography fixes interfere as well?
@pputzer: I haven’t done exhaustive tests as I don’t have time. My new WordPress website has been in development for almost 4 years and I have no other option but to test features as I go along. Sometimes I discover bugs like this that must be fixed.
With that in mind — do you have a solution? I didn’t get around to implementing a wrapper inserter in my math plugin yet and I’m wondering whether that would be optimal in this case.
Plugin Author
pepe
(@pputzer)
Not at the moment, but I’m in the process of preparing the task list for the next release and I’d like to know how deep this would have to go. Targeting a single fix is easier than all of them (if we dont want to resort to extra HTML elements.
A possible solution outside wp-Typography would be a small shortcode that adds the span around the expressions that should be ignored.
Alright. Then I will proceed with adding the wrapper via my plugin. In this case, the execution order of plugins becomes important. Once that’s done and dusted I’ll share the code with you.
Plugin Author
pepe
(@pputzer)
If you can wait another month, I could add some filter hooks to make skipping easier (preventing load order issues).
I have no idea π I will publish my website next week. Most likely, I won’t be using math in the beginning while testing out cross-posting etc., so maybe it can indeed wait.
Plugin Author
pepe
(@pputzer)
Hi @firelord, unfortunatly I didn’t put anything new for your problem in 5.6.0. However, can you tell me what plugins you are using for Mathjax integration? I’d like to set up a test environment to work out an efficient solution.
@pputzer: I’m using a custom plugin, more info here http://atdesign.ee/lire/
Direct link to download: http://atdesign.ee/lire/download/lire-wp-0.1.zip
It is heavily outdated, but still works.