Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raw math support #1071

Open
danieltuzes opened this issue Jan 16, 2025 · 6 comments
Open

raw math support #1071

danieltuzes opened this issue Jan 16, 2025 · 6 comments
Assignees
Labels
available-next-release Merged into the main branch but waiting for PyPI release enhancement Something that can better improve this extension
Milestone

Comments

@danieltuzes
Copy link

feature request: math support

Would it be possible to add raw math support? If confluence is set up so that it can accept raw html code, then math could be inserted in latex format, and MathJax could render it. What confluencebuilder needs to do here is to convert the :math:a^2 + b^2 = c^2`` to the format \(a^2 + b^2 = c^2\) and insert mathjax cdn link to the confluence page. Also with block math.

@jdknight
Copy link
Member

insert mathjax cdn link to the confluence page

To my knowledge, Confluence does not permit the injection of JavaScript HREF/resources. I am not sure how it would be possible to support MathJax.

This extension does support injecting math into LaTeX macros. Maybe this capability will work for you use case?

@danieltuzes
Copy link
Author

Injecting raw html is recommended to be disabled, but it may be enabled. For mermaid e.g. if you have don't have a solution to render the graph locally and upload the output, then you can still upload the graph source code and insert the mermaid renderer JS library via CDN, if raw html is enabled. With the confluence_html directive the developer can push raw html content to confluence, like <script src="https://cdn.jsdelivr.net/npm/[email protected]/+esm"></script>

So would it be possible, if there is a math block, you upload it as the math notation for mathjax? I'll include the necessary JS injection on the top of the rst file.

@jdknight
Copy link
Member

Mind trying the following branch:

pip install git+https://github.com/sphinx-contrib/confluencebuilder.git@math-playground

With the option:

confluence_raw_mathjax = True

(along with an injected mathjax directive)

If this works as expected, I'll cleanup the code and update documentation accordingly.

@danieltuzes
Copy link
Author

Yes, this works as expected:

  1. Used your new playground version
  2. added the option to conf.py, and have the confluencebuilder extension loaded
  3. used math block as usual, and added the confluence_html directive to the top of those pages, which inject the mathjax JS from a CDN
  4. The generated confluence page has the math code as expected, in the format for mathjax, and mathjax JS is present, and math is properly rendered by user's browser

I understand that a confluence instance where raw html is enabled is crucial (to get mathjax JS) and this is a strong limitation, but getting or enabling mathjax by confluence can now be pushed to other developers, and even in this form, can be used by some.

Thanks for the prompt feature implementation :)

@jdknight
Copy link
Member

Thanks for testing. I'll clean this up and get it into the development branch (which in turn should be available next release).

Might rename the configuration option to confluence_mathjax.

@jdknight jdknight added the enhancement Something that can better improve this extension label Jan 26, 2025
@jdknight jdknight self-assigned this Jan 26, 2025
@jdknight jdknight added this to the 2.10 milestone Jan 26, 2025
@jdknight
Copy link
Member

Support has been added into the development tree via #1075. The option has been finalized to confluence_mathjax.

@jdknight jdknight added the available-next-release Merged into the main branch but waiting for PyPI release label Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
available-next-release Merged into the main branch but waiting for PyPI release enhancement Something that can better improve this extension
Projects
None yet
Development

No branches or pull requests

2 participants