• Thank you for the plugin! Have been using it for years on several websites. But those did not use mathematics whereas a new site that I’m working on does (in the form of MathJax), so I discovered the following issue: If I use inline LaTeX code with MathJax, something like

    “…where $\gamma$ is a parameter …”

    then $\gamma$ turns into $\gam&shy;ma$. Since \gamma has no wrapper apart from $ … $, I cannot use the class ignore feature unless I wrap it into a separate <span class=”something”></span> which is a pain most of the time. As the author of the plugin, perhaps, you would have other suggestions?

Viewing 15 replies - 1 through 15 (of 28 total)
  • 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 &shy; etc. Mhm.

    Thread Starter Aleksei Tepljakov

    (@firelord)

    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 &shy; 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?

    Thread Starter Aleksei Tepljakov

    (@firelord)

    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 &shy; 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?

    Thread Starter Aleksei Tepljakov

    (@firelord)

    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 &shy;/hyphenation or are other typography fixes interfere as well?

    Thread Starter Aleksei Tepljakov

    (@firelord)

    @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.

    Thread Starter Aleksei Tepljakov

    (@firelord)

    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).

    Thread Starter Aleksei Tepljakov

    (@firelord)

    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.

    Thread Starter Aleksei Tepljakov

    (@firelord)

    @pputzer: I’m using a custom plugin, more info here https://atdesign.ee/lire/
    Direct link to download: https://atdesign.ee/lire/download/lire-wp-0.1.zip
    It is heavily outdated, but still works.

Viewing 15 replies - 1 through 15 (of 28 total)
  • The topic ‘Plugin interferes with inline parsing of mathematical formulae’ is closed to new replies.