Re: [PATCH] Re: Update Org to MathJax 3

2022-11-23 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Fixed now.

Fantastic!  And thank you again, Ihor, for the guidance.

Rudy
-- 
"I love deadlines.  I love the whooshing noise they make as they go by."
-- Douglas Adams, The Salmon of Doubt, 2002

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-23 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

>> I have replaced "MathJax 4" instances with "MathJax 3". I guess it was
>> a typo.
>
> The patch (correctly) distinguishes between:
>
> - MathJax 2 that we deprecated,
> - MathJax 3 that we now use by default, and
> - MathJax 4 that we support but do *not* use by default.

Oops. I did not see MathJax 4 on the website and missed the point.
Fixed now.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=7f4d91040a4fbf31fc78b250d4e47efb92e5fbd2

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-22 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Rudolf, I have applied your patch onto main with amendments.

Thank you!

> I have replaced "MathJax 4" instances with "MathJax 3". I guess it was
> a typo.

The patch (correctly) distinguishes between:

- MathJax 2 that we deprecated,
- MathJax 3 that we now use by default, and
- MathJax 4 that we support but do *not* use by default.

Most notably, MathJax 4 *re*-adds the support for (1) custom fonts and
(2) line breaks.  From the manual:

> Further, if you need to use a non-default ~font~ or ~linebreaks~ (now
> +~overflow~), then the ~path~ must point to MathJax 4 or later.

(The docstring also explicitly documents the two options as requiring
MathJax 4+.)

Even though MathJax 4 have yet to see a stable release, the patch works
with it, and the tests exercise every MathJax 4+ option as well.

Rationale:

(1) we can keep all the customization options from before,

(2) the more advanced users can use MathJax 4+ if they wish, and

(3) Org will need zero-to-none updates when 4 comes out [*].

[*]: In the expected case, we just updating the `path'.

Rudy
-- 
"Thinking is a momentary dismissal of irrelevancies."
-- Richard Buckminster Fuller, 1969

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-20 Thread Ihor Radchenko
Bastien Guerry  writes:

>> Or should we do something in
>> addition to announce backwards-incompatible change?
>
> I suggest to make this change visible on update.orgmode.org by sending
> an announcement to the list using X-Woof-Change: 9.6 as a header.

Done. Hopefully it is going to work:
https://orgmode.org/list/87o7t1ja2a.fsf@localhost

Rudolf, I have applied your patch onto main with amendments. I have
replaced "MathJax 4" instances with "MathJax 3". I guess it was a typo.
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=62e1513b5

Thanks a lot of the important contribution!

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-19 Thread Bastien Guerry
Ihor Radchenko  writes:

> Is the current news entry is sufficient? 

The ORG-NEWS entry in the patch looks good, thanks.

> Or should we do something in
> addition to announce backwards-incompatible change?

I suggest to make this change visible on update.orgmode.org by sending
an announcement to the list using X-Woof-Change: 9.6 as a header.

-- 
 Bastien



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-14 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  writes:
>
>> I note that you did not mention in the news that MathJax 2 support is
>> dropped. This is a very important thing we must highlight and ring all
>> the bells about.
>
> Fixed.  See the 8th revision of the patch attached below.  Better?

Thanks! Yes, better.

>> However, it could be at least a good idea to warn the users who are
>> trying to use MathJax 2.  Would it be possible?
>
> As far as I know, we have no reliable way of knowing the version of
> MathJax without actually reading the JavaScript file, locally and
> remotely.

I see. Then, we probably cannot have automatic and full backwards
compatibility anyway.

Before we proceed with the merge, I'd like to ping Bastien in case if he
has any objections.

Bastien, this is a breaking change that potentially affects the users
who use custom path to MathJax 2 in their config. Unfortunately, there
is no way to introduce MathJax 3 yet not breaking things for such users.
Is the current news entry is sufficient? Or should we do something in
addition to announce backwards-incompatible change?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-13 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> I note that you did not mention in the news that MathJax 2 support is
> dropped. This is a very important thing we must highlight and ring all
> the bells about.

Fixed.  See the 8th revision of the patch attached below.  Better?

> Consider that someone has customized path option to a local copy of
> MathJax version 2. Then, things will get broken after the update!

Correct, and we spell it out in the manual, in the "... and breaking
changes" section.

Digression [no comment needed; just venting]: This confirms, again, that
we should focus on LaTeX, the strength of Org, instead of defaulting to
the unstable world of JavaScript, copying popular Markdown editors that
have to use MathJax do due to their lack of integration with LaTeX.

> However, it could be at least a good idea to warn the users who are
> trying to use MathJax 2.  Would it be possible?

As far as I know, we have no reliable way of knowing the version of
MathJax without actually reading the JavaScript file, locally and
remotely.

Rudy
>From b886755450e052c3584e793fe0960914b0733001 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Fri, 7 Oct 2022 15:03:48 +0200
Subject: [PATCH] ox-html: Update from MathJax 2 to MathJax 3+

* lisp/ox-html.el (
org-html-mathjax-options,
org-html-mathjax-template,
org-html--build-mathjax-config
): Update from MathJax 2 to 3 while maintaining compatibility.  All
legacy options should continue to work, except for the 'path' option
which must now point to MathJax 3 or later.
* testing/lisp/test-ox-html.el (
ox-html/mathjax-path-none,
ox-html/mathjax-path-default,
ox-html/mathjax-path-custom,
ox-html/mathjax-path-in-buffer,
ox-html/mathjax-options-default,
ox-html/mathjax-options-custom,
ox-html/mathjax-options-in-buffer,
ox-html/mathjax-legacy-scale-default,
ox-html/mathjax-legacy-scale-custom,
ox-html/mathjax-legacy-scale-in-buffer,
ox-html/mathjax-legacy-scale-message,
ox-html/mathjax-legacy-scale-message-in-buffer,
ox-html/mathjax-legacy-scale-ignore,
ox-html/mathjax-legacy-autonumber-ams,
ox-html/mathjax-legacy-autonumber-ams-in-buffer,
ox-html/mathjax-legacy-autonumber-none,
ox-html/mathjax-legacy-autonumber-none-in-buffer,
ox-html/mathjax-legacy-autonumber-all,
ox-html/mathjax-legacy-autonumber-all-in-buffer,
ox-html/mathjax-legacy-autonumber-message,
ox-html/mathjax-legacy-autonumber-message-in-buffer,
ox-html/mathjax-legacy-font-tex,
ox-html/mathjax-legacy-font-tex-in-buffer,
ox-html/mathjax-legacy-font-stix-web,
ox-html/mathjax-legacy-font-stix-web-in-buffer,
ox-html/mathjax-legacy-font-asana-math,
ox-html/mathjax-legacy-font-asana-math-in-buffer,
ox-html/mathjax-legacy-font-neo-euler,
ox-html/mathjax-legacy-font-neo-euler-in-buffer,
ox-html/mathjax-legacy-font-gyre-pagella,
ox-html/mathjax-legacy-font-gyre-pagella-in-buffer,
ox-html/mathjax-legacy-font-gyre-termes,
ox-html/mathjax-legacy-font-gyre-termes-in-buffer,
ox-html/mathjax-legacy-font-latin-modern,
ox-html/mathjax-legacy-font-latin-modern-in-buffer,
ox-html/mathjax-legacy-line-breaks-true,
ox-html/mathjax-legacy-line-breaks-true-in-buffer,
ox-html/mathjax-legacy-line-breaks-false,
ox-html/mathjax-legacy-line-breaks-false-in-buffer,
ox-html/mathjax-legacy-line-breaks-message,
ox-html/mathjax-legacy-line-breaks-message-in-buffer): Test MathJax in
general and also the conversion of legacy options from MathJax 2 to 3.
* testing/org-test.el (org-test-capture-messages): Add a new macro
useful for testing the messages put in the echo area.
* etc/ORG-NEWS: Document MathJax 2 to 3 upgrade, highlighting the
benefits of the new version but also mentioning the fact that the user
may need to update the `path' option in `org-html-mathjax-options'.
* doc/org-manual.org (Math formatting in HTML export): Update the link
to the MathJax CDN and the example of how to use `+HTML_MATHJAX' with
MathJax 3.  Also, remove the note on MathJax extensions, as they did
not work (and do not work) as documented.

Link: https://list.orgmode.org/orgmode/m2a667n4ax@me.com/
---
 doc/org-manual.org   |  20 +-
 etc/ORG-NEWS |  38 ++
 lisp/ox-html.el  | 257 ---
 testing/lisp/test-ox-html.el | 818 +++
 testing/org-test.el  |  11 +
 5 files changed, 1063 insertions(+), 81 deletions(-)
 create mode 100644 testing/lisp/test-ox-html.el

diff --git a/doc/org-manual.org b/doc/org-manual.org
index dc2fc57cd..3514f84e4 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13228,24 +13228,20 @@ as-is.
 LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
 different ways on HTML pages.  The default is to use the
 [[https://www.mathjax.org][MathJax]], which should work out of the box
-with Org[fn:: By default Org loads MathJax from
-[[https://cdnjs.com][cdnjs.com]] as recommended by
-[[https://www.mathjax.org][MathJax]].][fn:46].  Some MathJax display
-options can be configured via ~org-html-mathjax-options~, or in the
-buffer.  For 

Re: [PATCH] Re: Update Org to MathJax 3

2022-11-12 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Below, I attach the 7th revision of the patch.

Thanks!

I note that you did not mention in the news that MathJax 2 support is
dropped. This is a very important thing we must highlight and ring all
the bells about.

Consider that someone has customized path option to a local copy of
MathJax version 2. Then, things will get broken after the update!

Of course, MathJax 2 is severely outdated, and we may not want to support
it completely (though see
https://orgmode.org/list/87h6z69myp.fsf@localhost). However, it could be
at least a good idea to warn the users who are trying to use MathJax 2.
Would it be possible?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-11 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Then, please mention this in the NEWS. Something like "we drop
> extension support as it never worked anyway".

Fixed.  I also reworded the surrounding text to match.

> You may even drop append and use ,@options inside `(...). Not a big
> deal though.

Fixed.

> If value is invalid string (not an actual number), `string-to-number'
> will return 0. This may cause very strange export output I think.

Fixed and added two new tests:

- ox-html/mathjax-legacy-scale-invalid
- ox-html/mathjax-legacy-scale-invalid-message

Below, I attach the 7th revision of the patch.

Rudy

>From 49f1dc5e58720c68546a2aedfeb8f87df60ac6cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Fri, 7 Oct 2022 15:03:48 +0200
Subject: [PATCH] ox-html: Update from MathJax 2 to MathJax 3+

* lisp/ox-html.el (
org-html-mathjax-options,
org-html-mathjax-template,
org-html--build-mathjax-config
): Update from MathJax 2 to 3 while maintaining compatibility.  All
legacy options should continue to work, except for the 'path' option
which must now point to MathJax 3 or later.
* testing/lisp/test-ox-html.el (
ox-html/mathjax-path-none,
ox-html/mathjax-path-default,
ox-html/mathjax-path-custom,
ox-html/mathjax-path-in-buffer,
ox-html/mathjax-options-default,
ox-html/mathjax-options-custom,
ox-html/mathjax-options-in-buffer,
ox-html/mathjax-legacy-scale-default,
ox-html/mathjax-legacy-scale-custom,
ox-html/mathjax-legacy-scale-in-buffer,
ox-html/mathjax-legacy-scale-message,
ox-html/mathjax-legacy-scale-message-in-buffer,
ox-html/mathjax-legacy-scale-ignore,
ox-html/mathjax-legacy-autonumber-ams,
ox-html/mathjax-legacy-autonumber-ams-in-buffer,
ox-html/mathjax-legacy-autonumber-none,
ox-html/mathjax-legacy-autonumber-none-in-buffer,
ox-html/mathjax-legacy-autonumber-all,
ox-html/mathjax-legacy-autonumber-all-in-buffer,
ox-html/mathjax-legacy-autonumber-message,
ox-html/mathjax-legacy-autonumber-message-in-buffer,
ox-html/mathjax-legacy-font-tex,
ox-html/mathjax-legacy-font-tex-in-buffer,
ox-html/mathjax-legacy-font-stix-web,
ox-html/mathjax-legacy-font-stix-web-in-buffer,
ox-html/mathjax-legacy-font-asana-math,
ox-html/mathjax-legacy-font-asana-math-in-buffer,
ox-html/mathjax-legacy-font-neo-euler,
ox-html/mathjax-legacy-font-neo-euler-in-buffer,
ox-html/mathjax-legacy-font-gyre-pagella,
ox-html/mathjax-legacy-font-gyre-pagella-in-buffer,
ox-html/mathjax-legacy-font-gyre-termes,
ox-html/mathjax-legacy-font-gyre-termes-in-buffer,
ox-html/mathjax-legacy-font-latin-modern,
ox-html/mathjax-legacy-font-latin-modern-in-buffer,
ox-html/mathjax-legacy-line-breaks-true,
ox-html/mathjax-legacy-line-breaks-true-in-buffer,
ox-html/mathjax-legacy-line-breaks-false,
ox-html/mathjax-legacy-line-breaks-false-in-buffer,
ox-html/mathjax-legacy-line-breaks-message,
ox-html/mathjax-legacy-line-breaks-message-in-buffer): Test MathJax in
general and also the conversion of legacy options from MathJax 2 to 3.
* testing/org-test.el (org-test-capture-messages): Add a new macro
useful for testing the messages put in the echo area.
* etc/ORG-NEWS: Document MathJax 2 to 3 upgrade, highlighting the
benefits of the new version but also mentioning the fact that the user
may need to update the `path' option in `org-html-mathjax-options'.
* doc/org-manual.org (Math formatting in HTML export): Update the link
to the MathJax CDN and the example of how to use `+HTML_MATHJAX' with
MathJax 3.  Also, remove the note on MathJax extensions, as they did
not work (and do not work) as documented.

Link: https://list.orgmode.org/orgmode/m2a667n4ax@me.com/
---
 doc/org-manual.org   |  20 +-
 etc/ORG-NEWS |  38 ++
 lisp/ox-html.el  | 257 ---
 testing/lisp/test-ox-html.el | 818 +++
 testing/org-test.el  |  11 +
 5 files changed, 1063 insertions(+), 81 deletions(-)
 create mode 100644 testing/lisp/test-ox-html.el

diff --git a/doc/org-manual.org b/doc/org-manual.org
index dc2fc57cd..3514f84e4 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13228,24 +13228,20 @@ as-is.
 LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
 different ways on HTML pages.  The default is to use the
 [[https://www.mathjax.org][MathJax]], which should work out of the box
-with Org[fn:: By default Org loads MathJax from
-[[https://cdnjs.com][cdnjs.com]] as recommended by
-[[https://www.mathjax.org][MathJax]].][fn:46].  Some MathJax display
-options can be configured via ~org-html-mathjax-options~, or in the
-buffer.  For example, with the following settings,
+with Org[fn:: By default, Org loads MathJax from
+[[https://www.jsdelivr.com/][jsDelivr]], as recommended in
+[[https://docs.mathjax.org/en/latest/web/start.html][Getting Started
+with MathJax Components]].][fn:46].  Some MathJax display options can
+be configured via ~org-html-mathjax-options~, or in the buffer.  For
+example, with the following settings,
 
 #+begin_example
-,#+HTML_MATHJAX: align: 

Re: [PATCH] Re: Update Org to MathJax 3

2022-11-09 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

>> Are these extensions no longer supported?
>
> MathJax 3+ supports extensions, and one can load them in multiple ways.
> See [1].  It deserves some thinking, for the extensions mirror LaTeX
> extensions.  So, to make both HTML and PDF work, one has:
>
>   Use the Physics package in both LaTeX and MathJax.
>
>   #+latex_header: \usepackage{physics}
>   
>   #+html_head_extra: 
>   #+html_head_extra:   \(
>   #+html_head_extra: \require{physics}
>   #+html_head_extra:   \)
>   #+html_head_extra: 
>
> (The example taken from my Org notebook.)
>
> [1]: https://docs.mathjax.org/en/latest/input/tex/extensions.html
>
> That said, I do not currently have bandwidth to extend the scope of the
> patch to include MathJax extensions.  (Note that they have never worked
> anyway, so the user loses nothing, and we correct documentation.)

Then, please mention this in the NEWS. Something like "we drop extension
support as it never worked anyway".

> A slight digression, just FYI:
>
> I realized that I should have improved LaTeX to SVG exports instead of
> focusing on MathJax.  Org supports LaTeX environments, but outside of
> PDFs, it does so poorly.  Packages such as TikZ, for example, do not
> work out of the box, so people use Babel to hack around it.  Worse
> still, Org does not even properly adjust baselines for inline math, so
> HTML exports remain barely usable for any mathematical work.
>
> If we fix LaTeX, Org could have fast and good mathematics, with no
> JavaScript, like Wikipedia has.  Then, we could use it by default,
> instead of MathJax.
>
> Having good support for LaTeX would position Org as the king of markup
> editors, because LaTeX can do everything under the sun.  For instance,
> one can typeset a chess game in a couple of lines.  Or sheet music.  Or
> molecules in three dimensions.  No mainstream Markdown editor or web
> authoring tool can do that.  Yet, Org can *almost* do it.

Patches are always welcome ;)

> + (append `((,(if (plist-member options 'autonumber)
> + 'tags 'autonumber)
> +nil)
> +   (,(if (plist-member options 'linebreaks)
> + 'overflow 'linebreaks)
> +nil))
> + options)))

You may even drop append and use ,@options inside `(...). Not a big deal though.

> +  (`scale
> +   (when (stringp value)
> + (setq value (string-to-number value)))
> +   (when (>= value 10)

If value is invalid string (not an actual number), `string-to-number'
will return 0. This may cause very strange export output I think. 

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-09 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Is it really recommended by mathjax?

Yes.

> I cannot find any mention of jsdelivr.com.

1. Open MathJax docs (https://docs.mathjax.org/en/latest/).
2. Type "jsDelivr" into the search box.
3. Check the search results.

> You may update the URL to something more precise.

Fixed.

> Are these extensions no longer supported?

MathJax 3+ supports extensions, and one can load them in multiple ways.
See [1].  It deserves some thinking, for the extensions mirror LaTeX
extensions.  So, to make both HTML and PDF work, one has:

  Use the Physics package in both LaTeX and MathJax.

  #+latex_header: \usepackage{physics}
  
  #+html_head_extra: 
  #+html_head_extra:   \(
  #+html_head_extra: \require{physics}
  #+html_head_extra:   \)
  #+html_head_extra: 

(The example taken from my Org notebook.)

[1]: https://docs.mathjax.org/en/latest/input/tex/extensions.html

That said, I do not currently have bandwidth to extend the scope of the
patch to include MathJax extensions.  (Note that they have never worked
anyway, so the user loses nothing, and we correct documentation.)

A slight digression, just FYI:

I realized that I should have improved LaTeX to SVG exports instead of
focusing on MathJax.  Org supports LaTeX environments, but outside of
PDFs, it does so poorly.  Packages such as TikZ, for example, do not
work out of the box, so people use Babel to hack around it.  Worse
still, Org does not even properly adjust baselines for inline math, so
HTML exports remain barely usable for any mathematical work.

If we fix LaTeX, Org could have fast and good mathematics, with no
JavaScript, like Wikipedia has.  Then, we could use it by default,
instead of MathJax.

Having good support for LaTeX would position Org as the king of markup
editors, because LaTeX can do everything under the sun.  For instance,
one can typeset a chess game in a couple of lines.  Or sheet music.  Or
molecules in three dimensions.  No mainstream Markdown editor or web
authoring tool can do that.  Yet, Org can *almost* do it.

> It would be more compact to use `(...) notation.

Fixed.

> nreverse will be more memory-efficient.

Fixed and TIL.

> Mostly because supporting MathJax 2 is an extra maintenance burden.  I
> do not see much point catering bugs of MathJax2 -> MathJax3
> conversion. If users want to use MathJax2 specifically, they should be
> able to customize Org to use MathJax2. If they want MathJax3, they
> need to fix the options. Relying on auto-conversion is calling for
> trouble.

Fixed.

Please see the 6th version of the patch, attached below.

P.S. I also replaced two subsequent `setq' calls with one.

Rudy
>From 5009350869879cce6f083a9b38961b95f1c51f58 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Fri, 7 Oct 2022 15:03:48 +0200
Subject: [PATCH] ox-html: Update from MathJax 2 to MathJax 3+

* lisp/ox-html.el (
org-html-mathjax-options,
org-html-mathjax-template,
org-html--build-mathjax-config
): Update from MathJax 2 to 3 while maintaining compatibility.  All
legacy options should continue to work, except for the 'path' option
which must now point to MathJax 3 or later.
* testing/lisp/test-ox-html.el (
ox-html/mathjax-path-none,
ox-html/mathjax-path-default,
ox-html/mathjax-path-custom,
ox-html/mathjax-path-in-buffer,
ox-html/mathjax-options-default,
ox-html/mathjax-options-custom,
ox-html/mathjax-options-in-buffer,
ox-html/mathjax-legacy-scale-default,
ox-html/mathjax-legacy-scale-custom,
ox-html/mathjax-legacy-scale-in-buffer,
ox-html/mathjax-legacy-scale-message,
ox-html/mathjax-legacy-scale-message-in-buffer,
ox-html/mathjax-legacy-scale-ignore,
ox-html/mathjax-legacy-autonumber-ams,
ox-html/mathjax-legacy-autonumber-ams-in-buffer,
ox-html/mathjax-legacy-autonumber-none,
ox-html/mathjax-legacy-autonumber-none-in-buffer,
ox-html/mathjax-legacy-autonumber-all,
ox-html/mathjax-legacy-autonumber-all-in-buffer,
ox-html/mathjax-legacy-autonumber-message,
ox-html/mathjax-legacy-autonumber-message-in-buffer,
ox-html/mathjax-legacy-font-tex,
ox-html/mathjax-legacy-font-tex-in-buffer,
ox-html/mathjax-legacy-font-stix-web,
ox-html/mathjax-legacy-font-stix-web-in-buffer,
ox-html/mathjax-legacy-font-asana-math,
ox-html/mathjax-legacy-font-asana-math-in-buffer,
ox-html/mathjax-legacy-font-neo-euler,
ox-html/mathjax-legacy-font-neo-euler-in-buffer,
ox-html/mathjax-legacy-font-gyre-pagella,
ox-html/mathjax-legacy-font-gyre-pagella-in-buffer,
ox-html/mathjax-legacy-font-gyre-termes,
ox-html/mathjax-legacy-font-gyre-termes-in-buffer,
ox-html/mathjax-legacy-font-latin-modern,
ox-html/mathjax-legacy-font-latin-modern-in-buffer,
ox-html/mathjax-legacy-line-breaks-true,
ox-html/mathjax-legacy-line-breaks-true-in-buffer,
ox-html/mathjax-legacy-line-breaks-false,
ox-html/mathjax-legacy-line-breaks-false-in-buffer,
ox-html/mathjax-legacy-line-breaks-message,
ox-html/mathjax-legacy-line-breaks-message-in-buffer): Test MathJax in
general and also the conversion of legacy options from MathJax 2 to 

Re: [PATCH] Re: Update Org to MathJax 3

2022-11-08 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Rudolf Adamkovič  writes:
>
>> See the 4th version of the patch attached below.
>
> And, of course, I forgot to update the commit message with the new
> macro.  Please see the 5th version of the patch attached below.

Thanks!

>  with Org[fn:: By default Org loads MathJax from
> -[[https://cdnjs.com][cdnjs.com]] as recommended by
> +[[https://www.jsdelivr.com/][jsDelivr]] as recommended by
>  [[https://www.mathjax.org][MathJax]].][fn:46].  Some MathJax display

Is it really recommended by mathjax? I cannot find any mention of
jsdelivr.com. You may update the URL to something more precise.

>  #+texinfo: @noindent
>  equation labels are displayed on the left margin and equations are
> -five em from the left margin.  In addition, it loads the two MathJax
> -extensions =cancel.js= and =noErrors.js=[fn:: See
> -[[https://docs.mathjax.org/en/latest/input/tex/extensions.html#tex-and-latex-extensions][TeX
> -and LaTeX extensions]] in the [[https://docs.mathjax.org][MathJax
> -manual]] to learn about extensions.].
> +five em from the left margin.

Are these extensions no longer supported?
  
> -   (options (plist-get info :html-mathjax-options))
> +   (options (let ((options (plist-get info :html-mathjax-options)))
> + ;; If the user customized some legacy option, set
> + ;; the corresponding new option to nil, so that
> + ;; the legacy user choice overrides the default.
> + ;; Otherwise, the user did not set the legacy
> + ;; option, in which case still set the legacy
> + ;; option but to no value, so that the code can
> + ;; find its in-buffer value, if set.
> + (append
> +  (list (list (if (plist-member options 'autonumber)
> +  'tags 'autonumber)
> +  nil)
> +(list (if (plist-member options 'linebreaks)
> +  'overflow 'linebreaks)
> +  nil))
> +  options)))

It would be more compact to use `(...) notation.
 
> +(defmacro org-test-capture-messages ( body)
> +  "Return the list of all messages put in the echo area by the BODY."
> +  ;; TODO Despite its name, this macro has nothing to do with Org and
> +  ;; belongs to a more general package in Emacs.
> +  (declare (indent 0) (debug t))
> +  `(let ((messages (list)))
> + (cl-letf (((symbol-function 'message)
> +(lambda (format-string  args)
> +  (setq messages
> +(cons (apply #'format
> + (cons format-string
> +   args))
> +  messages)
> +   ,@body)
> + (reverse messages)))

nreverse will be more memory-efficient.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-08 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

>> Also, I think that conversion message may worth a warning.
>
> You have mentioned this twice, but you have never said why.  I remain
> open, but I need know the reason.  To give you mine:
>
> We need to inform the user, not necessarily warn them.  They can keep
> using the older options as long as they want, and I engineered the patch
> specifically so that everything will work going forward, without the
> need for the user to spin the "update now" hamster wheel.
>
> However, if you have a sound, technical reason for issuing warnings to
> the user, I will make it happen.  Let me know!

Mostly because supporting MathJax 2 is an extra maintenance burden.
I do not see much point catering bugs of MathJax2 -> MathJax3
conversion. If users want to use MathJax2 specifically, they should be
able to customize Org to use MathJax2. If they want MathJax3, they need
to fix the options. Relying on auto-conversion is calling for trouble.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-08 Thread Rudolf Adamkovič
Rudolf Adamkovič  writes:

> See the 4th version of the patch attached below.

And, of course, I forgot to update the commit message with the new
macro.  Please see the 5th version of the patch attached below.

P.S. I also fixed a preposition in the documentation comment of the new
macro, now saying "in the BODY" instead of "by the BODY".

Rudy
>From 88b9ee017b89bb1a474786873f3d951c4b730cf3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Fri, 7 Oct 2022 15:03:48 +0200
Subject: [PATCH] ox-html: Update from MathJax 2 to MathJax 3+

* lisp/ox-html.el (
org-html-mathjax-options,
org-html-mathjax-template,
org-html--build-mathjax-config
): Update from MathJax 2 to 3 while maintaining compatibility.  All
legacy options should continue to work, except for the 'path' option
which must now point to MathJax 3 or later.
* testing/lisp/test-ox-html.el (
ox-html/mathjax-path-none,
ox-html/mathjax-path-default,
ox-html/mathjax-path-custom,
ox-html/mathjax-path-in-buffer,
ox-html/mathjax-options-default,
ox-html/mathjax-options-custom,
ox-html/mathjax-options-in-buffer,
ox-html/mathjax-legacy-scale-default,
ox-html/mathjax-legacy-scale-custom,
ox-html/mathjax-legacy-scale-in-buffer,
ox-html/mathjax-legacy-scale-message,
ox-html/mathjax-legacy-scale-message-in-buffer,
ox-html/mathjax-legacy-scale-ignore,
ox-html/mathjax-legacy-autonumber-ams,
ox-html/mathjax-legacy-autonumber-ams-in-buffer,
ox-html/mathjax-legacy-autonumber-none,
ox-html/mathjax-legacy-autonumber-none-in-buffer,
ox-html/mathjax-legacy-autonumber-all,
ox-html/mathjax-legacy-autonumber-all-in-buffer,
ox-html/mathjax-legacy-autonumber-message,
ox-html/mathjax-legacy-autonumber-message-in-buffer,
ox-html/mathjax-legacy-font-tex,
ox-html/mathjax-legacy-font-tex-in-buffer,
ox-html/mathjax-legacy-font-stix-web,
ox-html/mathjax-legacy-font-stix-web-in-buffer,
ox-html/mathjax-legacy-font-asana-math,
ox-html/mathjax-legacy-font-asana-math-in-buffer,
ox-html/mathjax-legacy-font-neo-euler,
ox-html/mathjax-legacy-font-neo-euler-in-buffer,
ox-html/mathjax-legacy-font-gyre-pagella,
ox-html/mathjax-legacy-font-gyre-pagella-in-buffer,
ox-html/mathjax-legacy-font-gyre-termes,
ox-html/mathjax-legacy-font-gyre-termes-in-buffer,
ox-html/mathjax-legacy-font-latin-modern,
ox-html/mathjax-legacy-font-latin-modern-in-buffer,
ox-html/mathjax-legacy-line-breaks-true,
ox-html/mathjax-legacy-line-breaks-true-in-buffer,
ox-html/mathjax-legacy-line-breaks-false,
ox-html/mathjax-legacy-line-breaks-false-in-buffer,
ox-html/mathjax-legacy-line-breaks-message,
ox-html/mathjax-legacy-line-breaks-message-in-buffer): Test MathJax in
general and also the conversion of legacy options from MathJax 2 to 3.
* testing/org-test.el (org-test-capture-messages): Add a new macro
useful for testing the messages put in the echo area.
* etc/ORG-NEWS: Document MathJax 2 to 3 upgrade, highlighting the
benefits of the new version but also mentioning the fact that the user
may need to update the `path' option in `org-html-mathjax-options'.
* doc/org-manual.org (Math formatting in HTML export): Update the link
to the MathJax CDN and the example of how to use `+HTML_MATHJAX' with
MathJax 3.  Also, remove the note on MathJax extensions, as they did
not work (and do not work) as documented.

Link: https://list.orgmode.org/orgmode/m2a667n4ax@me.com/
---
 doc/org-manual.org   |  11 +-
 etc/ORG-NEWS |  32 ++
 lisp/ox-html.el  | 240 ---
 testing/lisp/test-ox-html.el | 785 +++
 testing/org-test.el  |  16 +
 5 files changed, 1010 insertions(+), 74 deletions(-)
 create mode 100644 testing/lisp/test-ox-html.el

diff --git a/doc/org-manual.org b/doc/org-manual.org
index dc2fc57cd..7500202c5 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13229,23 +13229,18 @@ LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
 different ways on HTML pages.  The default is to use the
 [[https://www.mathjax.org][MathJax]], which should work out of the box
 with Org[fn:: By default Org loads MathJax from
-[[https://cdnjs.com][cdnjs.com]] as recommended by
+[[https://www.jsdelivr.com/][jsDelivr]] as recommended by
 [[https://www.mathjax.org][MathJax]].][fn:46].  Some MathJax display
 options can be configured via ~org-html-mathjax-options~, or in the
 buffer.  For example, with the following settings,
 
 #+begin_example
-,#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
-,#+HTML_MATHJAX: cancel.js noErrors.js
+,#+HTML_MATHJAX: align: left indent: 5em tagside: left
 #+end_example
 
 #+texinfo: @noindent
 equation labels are displayed on the left margin and equations are
-five em from the left margin.  In addition, it loads the two MathJax
-extensions =cancel.js= and =noErrors.js=[fn:: See
-[[https://docs.mathjax.org/en/latest/input/tex/extensions.html#tex-and-latex-extensions][TeX
-and LaTeX extensions]] in the [[https://docs.mathjax.org][MathJax
-manual]] to learn about 

Re: [PATCH] Re: Update Org to MathJax 3

2022-11-08 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Then, you can `cl-letf'-bind the message function in a new macro added
> to org-test.el. The binding will accumulate messages in some
> list. Then, use that macro to test the messages.

What a great piece of advice.  Thank you, Ihor!

See the 4th version of the patch attached below.

> Also, I think that conversion message may worth a warning.

You have mentioned this twice, but you have never said why.  I remain
open, but I need know the reason.  To give you mine:

We need to inform the user, not necessarily warn them.  They can keep
using the older options as long as they want, and I engineered the patch
specifically so that everything will work going forward, without the
need for the user to spin the "update now" hamster wheel.

However, if you have a sound, technical reason for issuing warnings to
the user, I will make it happen.  Let me know!

Rudy
>From 8d23b1f6f8a964f2f27499147ee977344d8719a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Fri, 7 Oct 2022 15:03:48 +0200
Subject: [PATCH] ox-html: Update from MathJax 2 to MathJax 3+

* lisp/ox-html.el (
org-html-mathjax-options,
org-html-mathjax-template,
org-html--build-mathjax-config
): Update from MathJax 2 to 3 while maintaining compatibility.  All
legacy options should continue to work, except for the 'path' option
which must now point to MathJax 3 or later.
* testing/lisp/test-ox-html.el (
ox-html/mathjax-path-none,
ox-html/mathjax-path-default,
ox-html/mathjax-path-custom,
ox-html/mathjax-path-in-buffer,
ox-html/mathjax-options-default,
ox-html/mathjax-options-custom,
ox-html/mathjax-options-in-buffer,
ox-html/mathjax-legacy-scale-default,
ox-html/mathjax-legacy-scale-custom,
ox-html/mathjax-legacy-scale-in-buffer,
ox-html/mathjax-legacy-scale-message,
ox-html/mathjax-legacy-scale-message-in-buffer,
ox-html/mathjax-legacy-scale-ignore,
ox-html/mathjax-legacy-autonumber-ams,
ox-html/mathjax-legacy-autonumber-ams-in-buffer,
ox-html/mathjax-legacy-autonumber-none,
ox-html/mathjax-legacy-autonumber-none-in-buffer,
ox-html/mathjax-legacy-autonumber-all,
ox-html/mathjax-legacy-autonumber-all-in-buffer,
ox-html/mathjax-legacy-autonumber-message,
ox-html/mathjax-legacy-autonumber-message-in-buffer,
ox-html/mathjax-legacy-font-tex,
ox-html/mathjax-legacy-font-tex-in-buffer,
ox-html/mathjax-legacy-font-stix-web,
ox-html/mathjax-legacy-font-stix-web-in-buffer,
ox-html/mathjax-legacy-font-asana-math,
ox-html/mathjax-legacy-font-asana-math-in-buffer,
ox-html/mathjax-legacy-font-neo-euler,
ox-html/mathjax-legacy-font-neo-euler-in-buffer,
ox-html/mathjax-legacy-font-gyre-pagella,
ox-html/mathjax-legacy-font-gyre-pagella-in-buffer,
ox-html/mathjax-legacy-font-gyre-termes,
ox-html/mathjax-legacy-font-gyre-termes-in-buffer,
ox-html/mathjax-legacy-font-latin-modern,
ox-html/mathjax-legacy-font-latin-modern-in-buffer,
ox-html/mathjax-legacy-line-breaks-true,
ox-html/mathjax-legacy-line-breaks-true-in-buffer,
ox-html/mathjax-legacy-line-breaks-false,
ox-html/mathjax-legacy-line-breaks-false-in-buffer,
ox-html/mathjax-legacy-line-breaks-message,
ox-html/mathjax-legacy-line-breaks-message-in-buffer): Test MathJax in
general and also the conversion of legacy options from MathJax 2 to 3.
* etc/ORG-NEWS: Document MathJax 2 to 3 upgrade, highlighting the
benefits of the new version but also mentioning the fact that the user
may need to update the `path' option in `org-html-mathjax-options'.
* doc/org-manual.org (Math formatting in HTML export): Update the link
to the MathJax CDN and the example of how to use `+HTML_MATHJAX' with
MathJax 3.  Also, remove the note on MathJax extensions, as they did
not work (and do not work) as documented.

Link: https://list.orgmode.org/orgmode/m2a667n4ax@me.com/
---
 doc/org-manual.org   |  11 +-
 etc/ORG-NEWS |  32 ++
 lisp/ox-html.el  | 240 ---
 testing/lisp/test-ox-html.el | 785 +++
 testing/org-test.el  |  16 +
 5 files changed, 1010 insertions(+), 74 deletions(-)
 create mode 100644 testing/lisp/test-ox-html.el

diff --git a/doc/org-manual.org b/doc/org-manual.org
index dc2fc57cd..7500202c5 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13229,23 +13229,18 @@ LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
 different ways on HTML pages.  The default is to use the
 [[https://www.mathjax.org][MathJax]], which should work out of the box
 with Org[fn:: By default Org loads MathJax from
-[[https://cdnjs.com][cdnjs.com]] as recommended by
+[[https://www.jsdelivr.com/][jsDelivr]] as recommended by
 [[https://www.mathjax.org][MathJax]].][fn:46].  Some MathJax display
 options can be configured via ~org-html-mathjax-options~, or in the
 buffer.  For example, with the following settings,
 
 #+begin_example
-,#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
-,#+HTML_MATHJAX: cancel.js noErrors.js
+,#+HTML_MATHJAX: align: left indent: 5em tagside: 

Re: [PATCH] Re: Update Org to MathJax 3

2022-11-07 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Ihor Radchenko  writes:
>
>> The proper test is not presence of the message, but the correct
>> conversion of the legacy options in the actual html output.
>
> We do test the results in the HTML output, of course.  Still, I would
> like to test the user messages too.

Then, you can `cl-letf'-bind the message function in a new macro added
to org-test.el. The binding will accumulate messages in some list. Then,
use that macro to test the messages.

Also, I think that conversion message may worth a warning.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-07 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> The proper test is not presence of the message, but the correct
> conversion of the legacy options in the actual html output.

We do test the results in the HTML output, of course.  Still, I would
like to test the user messages too.  By my definition, "proper" tests
verify all requirements.  Hence, I ask: Do we want to reliably notify
the user?  If we do not, we can remove the messages.  If we do, then we
either test the messages or they will break at some random point in time
and generate yet another pointless mail thread.

If we do not have any better idea, then I can define a variable that
points to the 'message' function by default.  The relevant tests can
then set the variable to a function that gathers messages in a list.
With that, the tests can verify that the list contains exactly one
instance of the expected message.

Rudy
-- 
"It is no paradox to say that in our most theoretical moods we may be
nearest to our most practical applications."
-- Alfred North Whitehead, 1861-1947

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-06 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Bummer!  Do you have any suggestions in mind?  Perhaps we could define
> an advice for '(current-message)', if that ever runs?  I would welcome
> any ideas.

Using `current-message' would not be reliable even if it worked. It is
not future-compatible if we decide to emit new messages during export.

The proper test is not presence of the message, but the correct
conversion of the legacy options in the actual html output.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-06 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

> Nothing is attached.

I apologize.  Please see the attached patch.

> If you are using Emacs to send email, I suggest you to enable checks
> for attachments, as I do in notmuch [...]

TIL and thank you!  Added to my configuration.

> AFAIK, `current-message' always returns nil in noninteractive batch
> mode. Messages are written directly into stderr. You need to use a
> different approach for testing.
>
>> P.S. As a workaround I also tried to set `set-message-function',
>> dependency-injection style, but it did not work either.
>
> I do not think that this function is ever executed in noninteractive
> mode either.

Bummer!  Do you have any suggestions in mind?  Perhaps we could define
an advice for '(current-message)', if that ever runs?  I would welcome
any ideas.

Rudy

>From 7bdc7cbd7e6f5c06773138657325502adc2fe999 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Fri, 7 Oct 2022 15:03:48 +0200
Subject: [PATCH] ox-html: Update from MathJax 2 to MathJax 3+

* lisp/ox-html.el (
org-html-mathjax-options,
org-html-mathjax-template,
org-html--build-mathjax-config
): Update from MathJax 2 to 3 while maintaining compatibility.  All
legacy options should continue to work, except for the 'path' option
which must now point to MathJax 3 or later.
* testing/lisp/test-ox-html.el (
ox-html/mathjax-path-none,
ox-html/mathjax-path-default,
ox-html/mathjax-path-custom,
ox-html/mathjax-path-in-buffer,
ox-html/mathjax-options-default,
ox-html/mathjax-options-custom,
ox-html/mathjax-options-in-buffer,
ox-html/mathjax-legacy-scale-default,
ox-html/mathjax-legacy-scale-custom,
ox-html/mathjax-legacy-scale-in-buffer,
ox-html/mathjax-legacy-scale-message,
ox-html/mathjax-legacy-scale-message-in-buffer,
ox-html/mathjax-legacy-scale-ignore,
ox-html/mathjax-legacy-autonumber-ams,
ox-html/mathjax-legacy-autonumber-ams-in-buffer,
ox-html/mathjax-legacy-autonumber-none,
ox-html/mathjax-legacy-autonumber-none-in-buffer,
ox-html/mathjax-legacy-autonumber-all,
ox-html/mathjax-legacy-autonumber-all-in-buffer,
ox-html/mathjax-legacy-autonumber-message,
ox-html/mathjax-legacy-autonumber-message-in-buffer,
ox-html/mathjax-legacy-font-tex,
ox-html/mathjax-legacy-font-tex-in-buffer,
ox-html/mathjax-legacy-font-stix-web,
ox-html/mathjax-legacy-font-stix-web-in-buffer,
ox-html/mathjax-legacy-font-asana-math,
ox-html/mathjax-legacy-font-asana-math-in-buffer,
ox-html/mathjax-legacy-font-neo-euler,
ox-html/mathjax-legacy-font-neo-euler-in-buffer,
ox-html/mathjax-legacy-font-gyre-pagella,
ox-html/mathjax-legacy-font-gyre-pagella-in-buffer,
ox-html/mathjax-legacy-font-gyre-termes,
ox-html/mathjax-legacy-font-gyre-termes-in-buffer,
ox-html/mathjax-legacy-font-latin-modern,
ox-html/mathjax-legacy-font-latin-modern-in-buffer,
ox-html/mathjax-legacy-line-breaks-true,
ox-html/mathjax-legacy-line-breaks-true-in-buffer,
ox-html/mathjax-legacy-line-breaks-false,
ox-html/mathjax-legacy-line-breaks-false-in-buffer,
ox-html/mathjax-legacy-line-breaks-message,
ox-html/mathjax-legacy-line-breaks-message-in-buffer): Test MathJax in
general and also the conversion of legacy options from MathJax 2 to 3.
* etc/ORG-NEWS: Document MathJax 2 to 3 upgrade, highlighting the
benefits of the new version but also mentioning the fact that the user
may need to update the `path' option in `org-html-mathjax-options'.
* doc/org-manual.org (Math formatting in HTML export): Update the link
to the MathJax CDN and the example of how to use `+HTML_MATHJAX' with
MathJax 3.  Also, remove the note on MathJax extensions, as they did
not work (and do not work) as documented.

Link: https://list.orgmode.org/orgmode/m2a667n4ax@me.com/
---
 doc/org-manual.org   |  11 +-
 etc/ORG-NEWS |  32 ++
 lisp/ox-html.el  | 240 ---
 testing/lisp/test-ox-html.el | 762 +++
 4 files changed, 971 insertions(+), 74 deletions(-)
 create mode 100644 testing/lisp/test-ox-html.el

diff --git a/doc/org-manual.org b/doc/org-manual.org
index dc2fc57cd..7500202c5 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -13229,23 +13229,18 @@ LaTeX math snippets (see [[*LaTeX fragments]]) can be displayed in two
 different ways on HTML pages.  The default is to use the
 [[https://www.mathjax.org][MathJax]], which should work out of the box
 with Org[fn:: By default Org loads MathJax from
-[[https://cdnjs.com][cdnjs.com]] as recommended by
+[[https://www.jsdelivr.com/][jsDelivr]] as recommended by
 [[https://www.mathjax.org][MathJax]].][fn:46].  Some MathJax display
 options can be configured via ~org-html-mathjax-options~, or in the
 buffer.  For example, with the following settings,
 
 #+begin_example
-,#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Euler
-,#+HTML_MATHJAX: cancel.js noErrors.js
+,#+HTML_MATHJAX: align: left indent: 5em tagside: left
 #+end_example
 
 #+texinfo: @noindent
 equation labels are displayed on the left margin and equations are
-five em 

Re: [PATCH] Re: Update Org to MathJax 3

2022-11-05 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Rudolf Adamkovič  writes:
>
>> Good points; I will fix everything.
>
> Please see the attached (3rd) revision of the patch.

Nothing is attached.
If you are using Emacs to send email, I suggest you to enable checks for
attachments, as I do in notmuch
(add-hook 'notmuch-mua-send-hook #'notmuch-mua-attachment-check)

I am sure that similar functionality exists in other Emacs mail clients.

> It seems that some part of the *batch* testing swallows the messages in
> a way that makes `(current-message)' work incorrectly in tests.
>
> Any ideas?  Asking for an Emacs veteran.  :)

AFAIK, `current-message' always returns nil in noninteractive batch
mode. Messages are written directly into stderr. You need to use a
different approach for testing.

> P.S. As a workaround I also tried to set `set-message-function',
> dependency-injection style, but it did not work either.

I do not think that this function is ever executed in noninteractive
mode either.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-05 Thread Rudolf Adamkovič
Rudolf Adamkovič  writes:

> Good points; I will fix everything.

Please see the attached (3rd) revision of the patch.

However, the tests still fail when ran via `make test'.  See below.

> Ihor Radchenko  writes:
>
>> Your tests are failing on my side...
>
> The tests *pass* when ran in-buffer but *fail* when ran via 'make
> test'.  Just the tests that call (current-message) have this problem.
> Interesting.

I cannot figure out why these tests pass when ran from inside of Emacs
but fail when ran via 'make tests'.  I found in `default.mk' that Make
runs `ert-run-tests-batch', but even that *passes* from within Emacs:

1. load `testing/org-test.el',

2. evaluate `ox-html/mathjax-legacy-scale-message-in-buffer` test in
`testing/lisp/test-ox-html.el', and

3. run `M-: ert-run-tests-batch'.

It produces the following output in the `*Messages*' buffer:

  Running 1 tests (2022-11-05 23:17:56+0100, selector ‘t’)
  Converting legacy MathJax scale: 20 to 0.2
 passed  1/1  ox-html/mathjax-legacy-scale-message-in-buffer (0.008186 sec)
  
  Ran 1 tests, 1 results as expected, 0 unexpected (2022-11-05 23:17:56+0100, 
0.010790 sec)

It seems that some part of the *batch* testing swallows the messages in
a way that makes `(current-message)' work incorrectly in tests.

Any ideas?  Asking for an Emacs veteran.  :)

P.S. As a workaround I also tried to set `set-message-function',
dependency-injection style, but it did not work either.

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
-- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-05 Thread Rudolf Adamkovič
Ihor Radchenko  writes:

Thank you for taking a look, Ihor!

> Your tests are failing on my side...

Oh, I see!  The tests *pass* when ran in-buffer but *fail* when ran via
'make test'.  Just the tests that call (current-message) have this
problem.  Interesting.

> ...

Good points; I will fix everything.

Rudy
-- 
"'Contrariwise,' continued Tweedledee, 'if it was so, it might be; and
if it were so, it would be; but as it isn't, it ain't.  That's logic.'"
-- Lewis Carroll, Through the Looking Glass, 1871/1872

Rudolf Adamkovič  [he/him]
Studenohorská 25
84103 Bratislava
Slovakia



Re: [PATCH] Re: Update Org to MathJax 3

2022-11-05 Thread Ihor Radchenko
Rudolf Adamkovič  writes:

> Rudolf Adamkovič  writes:
>
>> I will resurrect the thread when I have something to show.
>
> All right, I have finished the second version of the patch.

Thanks!

> What do you think?

Your tests are failing on my side...


Also,

In org-html--build-mathjax-config:
ox-html.el:1999:40: Warning: malformed cond form: ‘nil’

I'll wait for a new version of the patch with tests passing before I do
a more elaborate review.

Some quick comments below.

> ox-html/mathjax-legacy-line-breaks-message-in-buffer): Test MathJax.

You forgot changelog entries for ORG-NEWS.

Also, you did not update the relevant manual sections.

> Reported-by: Rudolf Adamkovič 

There is no need to add Reported-by here. It is not a bug.

> +*** HTML export uses MathJax 3+ instead of MathJax 2
> +
> +Org 9.6 uses MathJax 3, a ground-up rewrite of MathJax 2 released
> +in 2019.  The new version brings modularity, better and faster
> +rendering, improved LaTeX support, and more.
> +
> +For more information about new features, see:
> +
> +https://docs.mathjax.org/en/latest/upgrading/whats-new-3.0.html
> +https://docs.mathjax.org/en/latest/upgrading/whats-new-3.1.html
> +https://docs.mathjax.org/en/latest/upgrading/whats-new-3.2.html

This paragraph would look better at the end, after you discuss specific
features.

> +
> +See the updated =org-html-mathjax-options= for more details.

Please use code markup for symbols:  ~org-html-mathjax-options~.

>  (defcustom org-html-mathjax-options
> -  '((path 
> "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML;
>  )
> -(scale "100")
> +  '((path "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js;)
> +(scale 1.0)

It will be worth mentioning that we change the JS provider.
People at least need to take note about different privacy policy.

> +  (when value
> +(pcase symbol
> +  ('font

It is recommended to use backquote `font in favor of direct quote 'font.

> +   (when-let
> +   ((new-value (cond
> +((string= value "TeX")

> + "mathjax-tex")
> +((string= value "STIX-Web")
> + "mathjax-stix2")
> +((string= value "Asana-Math")
> + "mathjax-asana")
> +((string= value "Neo-Euler")
> + "mathjax-euler")
> +((string= value "Gyre-Pagella")
> + "mathjax-pagella")
> +((string= value "Gyre-Termes")
> + "mathjax-termes")
> +((string= value "Latin-Modern")
> + "mathjax-modern")
> +nil)))

Why not pcase?


> + (setq value new-value)))
> +  ('linebreaks
> +   (message "Converting legacy MathJax option: linebreaks")

Maybe warning?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at .
Support Org development at ,
or support my work at 



[PATCH] Re: Update Org to MathJax 3

2022-11-04 Thread Rudolf Adamkovič
Rudolf Adamkovič  writes:

> I will resurrect the thread when I have something to show.

All right, I have finished the second version of the patch.

What do you think?

Rudy

>From aee823f34498cccd6c08bcedb177c82d5de40269 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rudolf=20Adamkovi=C4=8D?= 
Date: Fri, 7 Oct 2022 15:03:48 +0200
Subject: [PATCH] ox-html: Update from MathJax 2 to MathJax 3+
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* lisp/ox-html.el (
org-html-mathjax-options,
org-html-mathjax-template,
org-html--build-mathjax-config
): Update to MathJax 3 while maintaining compatibility with MathJax 2.
All legacy options get converted automatically, except for the 'path'
option which must now point to MathJax 3 or later and not MathJax 2.
* testing/lisp/test-ox-html.el (
ox-html/mathjax-path-none,
ox-html/mathjax-path-default,
ox-html/mathjax-path-custom,
ox-html/mathjax-path-in-buffer,
ox-html/mathjax-options-default,
ox-html/mathjax-options-custom,
ox-html/mathjax-options-in-buffer,
ox-html/mathjax-legacy-scale-default,
ox-html/mathjax-legacy-scale-custom,
ox-html/mathjax-legacy-scale-in-buffer,
ox-html/mathjax-legacy-scale-message,
ox-html/mathjax-legacy-scale-message-in-buffer,
ox-html/mathjax-legacy-scale-ignore,
ox-html/mathjax-legacy-autonumber-ams,
ox-html/mathjax-legacy-autonumber-ams-in-buffer,
ox-html/mathjax-legacy-autonumber-none,
ox-html/mathjax-legacy-autonumber-none-in-buffer,
ox-html/mathjax-legacy-autonumber-all,
ox-html/mathjax-legacy-autonumber-all-in-buffer,
ox-html/mathjax-legacy-autonumber-message,
ox-html/mathjax-legacy-autonumber-message-in-buffer,
ox-html/mathjax-legacy-font-tex,
ox-html/mathjax-legacy-font-tex-in-buffer,
ox-html/mathjax-legacy-font-stix-web,
ox-html/mathjax-legacy-font-stix-web-in-buffer,
ox-html/mathjax-legacy-font-asana-math,
ox-html/mathjax-legacy-font-asana-math-in-buffer,
ox-html/mathjax-legacy-font-neo-euler,
ox-html/mathjax-legacy-font-neo-euler-in-buffer,
ox-html/mathjax-legacy-font-gyre-pagella,
ox-html/mathjax-legacy-font-gyre-pagella-in-buffer,
ox-html/mathjax-legacy-font-gyre-termes,
ox-html/mathjax-legacy-font-gyre-termes-in-buffer,
ox-html/mathjax-legacy-font-latin-modern,
ox-html/mathjax-legacy-font-latin-modern-in-buffer,
ox-html/mathjax-legacy-line-breaks-true,
ox-html/mathjax-legacy-line-breaks-true-in-buffer,
ox-html/mathjax-legacy-line-breaks-false,
ox-html/mathjax-legacy-line-breaks-false-in-buffer,
ox-html/mathjax-legacy-line-breaks-message,
ox-html/mathjax-legacy-line-breaks-message-in-buffer): Test MathJax.

Reported-by: Rudolf Adamkovič 
Link: https://list.orgmode.org/orgmode/m2a667n4ax@me.com/
---
 etc/ORG-NEWS |  25 ++
 lisp/ox-html.el  | 247 +---
 testing/lisp/test-ox-html.el | 762 +++
 3 files changed, 968 insertions(+), 66 deletions(-)
 create mode 100644 testing/lisp/test-ox-html.el

diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index b542da34b..7ad17bd70 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -139,6 +139,31 @@ rely on the details of visibility state implementation in
 backend.  From now on, using =outline-*= functions is strongly
 discouraged when working with Org files.
 
+*** HTML export uses MathJax 3+ instead of MathJax 2
+
+Org 9.6 uses MathJax 3, a ground-up rewrite of MathJax 2 released
+in 2019.  The new version brings modularity, better and faster
+rendering, improved LaTeX support, and more.
+
+For more information about new features, see:
+
+https://docs.mathjax.org/en/latest/upgrading/whats-new-3.0.html
+https://docs.mathjax.org/en/latest/upgrading/whats-new-3.1.html
+https://docs.mathjax.org/en/latest/upgrading/whats-new-3.2.html
+
+For instance, one can typeset calculus with the built-in =physics=
+package or chemistry with the built-in =mhchem= package, like in
+LaTeX.
+
+During the export, Org automatically converts all legacy MathJax 2
+options to the corresponding MathJax 3+ options, except for the =path=
+which must now point to a file containing MathJax version 3 or later.
+
+Further, if you need to use a non-default =font= or =linebreaks= (now
+=overflow=), then the =path= must point to MathJax 4 or later.
+
+See the updated =org-html-mathjax-options= for more details.
+
 ** New features
 *** Clock table can now produce quarterly reports
 
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index cad06aebf..9436623e0 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -1166,72 +1166,116 @@ See `format-time-string' for more information on its components."
  Template :: Mathjax
 
 (defcustom org-html-mathjax-options
-  '((path "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js?config=TeX-AMS_HTML; )
-(scale "100")
+  '((path "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js;)
+(scale 1.0)
 (align "center")
-(font "TeX")
-(linebreaks "false")
-(autonumber "AMS")
+(font "mathjax-modern")
+(overflow "overflow")
+(tags "ams")