MathJax not working in Title field

Created on 26 May 2025, about 1 month ago

Problem/Motivation

MathJax is not working in Title field; does work in abstract.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡―πŸ‡΅Japan kazu furutaka

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kazu furutaka
  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

    I was unable to reproduce this behavior. Here are the steps I took.

    1. Add the CDN script to the HTML head of the site as indicated on https://www.mathjax.org/#gettingstarted
    2. Populate a reference title field with MathJax syntax, such as the following:

     When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
      \[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]

    3. View the reference entity. The MathJax logic does convert the shortcode syntax as expected.

    (Note that the conversion won't necessarily happen in the *administrative* portion of the site if you are using a different admin theme and the JS script has not been added to that theme. If you want it to work in the admin theme, you would need to do something like a hook_page_attachments implementation (see https://www.drupal.org/docs/develop/creating-modules/adding-assets-css-j... β†’ ):

    mymodule.module:

    /**
     * Implements hook_page_attachments().
     */
    function mymodule_page_attachments(array &$attachments) {
      $attachments['#attached']['library'][] = 'mymodule/mathjax';
    }
    

    mymodule.libraries.yml:

    mathjax:
      js:
        https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js: { type: external, minified: true }
    
  • πŸ‡―πŸ‡΅Japan kazu furutaka

    Hi, @mark_fullmer...
    Thanks for your comment.

    I was unable to reproduce this behavior. Here are the steps I took.

    These are a test entry (conference paper) and its preview I got; again, although the summary sentence is correctly converted, title etc. are not...

  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

    If you inspect the rendering of the title field, are the characters encoded or escaped? Also, if you can confirm that this is not happening on a basic node, such as "Basic Page," then this would seem to not be relate to Bibcite and you could search Drupal core issues for similar reports.

  • πŸ‡―πŸ‡΅Japan kazu furutaka

    Well, indeed, I found that even the title of a basic page isn't converted.

    I also found the following article, but could not get a working configuration... sigh...
    https://www.drupal.org/project/mathjax/issues/2308301 πŸ’¬ How to use a custom configuration to process math in titles Fixed

    Can anyone help me?

  • πŸ‡―πŸ‡΅Japan kazu furutaka

    Argh...
    Strange enough, now it's working...
    Procedure:

    1. In Mathjax configuration, choose "Custom" Configuration type,
    2. put/leave the default "Custom configuration" string stored in /modules/contrib/mathjax/config/install/mathjax.settings.yml as default_config_string: {"tex2jax":{"inlineMath":[["$","$"],["\\(","\\)"]], "processEscapes":"true"},"showProcessingMessages":"false","messageStyle":"none"}
    3. "Save configuration"
    4. go to /admin/config/development/performance and "Clear all caches",
    5. "Save configuration."

    After choosing "Text Format" instead for the Mathjax "Configuration type" and follow the same procedure as above (3., 4. and 5.), I got the same result as before; although summary text is properly converted, title is not...

    Can someone reproduce/confirm the above?

    Although working now, I'm totally confused. Why are the result of "Custom configuration" using the "default" configuration string and that by choosing "Text Format" differ??? (isn't the latter the default?)

    I'm sorry for all the fuss...
    Kazuyoshi

  • πŸ‡ΊπŸ‡ΈUnited States mark_fullmer Tucson

    Okay, thanks for the update. I'll go ahead and close this issue.

Production build 0.71.5 2024