[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: Only put extra settings in MATHJAX_CONFIGURATION
From: |
Gavin D. Smith |
Subject: |
branch master updated: Only put extra settings in MATHJAX_CONFIGURATION |
Date: |
Sun, 13 Oct 2024 07:14:40 -0400 |
This is an automated email from the git hooks/post-receive script.
gavin pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new a4d0c5811c Only put extra settings in MATHJAX_CONFIGURATION
a4d0c5811c is described below
commit a4d0c5811c0f9fac2fd77dc4bedba968a3a37fb0
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Sun Oct 13 12:14:20 2024 +0100
Only put extra settings in MATHJAX_CONFIGURATION
* tp/Texinfo/Convert/HTML.pm (_setup_output): do not set
MATHJAX_CONFIGURATION.
(_file_header_information) <MathJax>: Move default MathJax
configuration here from _setup_output. Always output it.
Only output value of MATHJAX_CONFIGURATION if set.
* doc/texinfo.texi (MathJax Customization Variables): update.
do not show default texi2any configuration of MathJax.
---
ChangeLog | 12 ++++++++++
doc/texinfo.texi | 45 ++++++++++++++++++----------------
tp/Texinfo/Convert/HTML.pm | 60 +++++++++++++++++++++++++++++-----------------
3 files changed, 75 insertions(+), 42 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 1e71278c83..95d5e9d184 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-10-13 Gavin Smith <gavinsmith0123@gmail.com>
+
+ Only put extra settings in MATHJAX_CONFIGURATION
+
+ * tp/Texinfo/Convert/HTML.pm (_setup_output): do not set
+ MATHJAX_CONFIGURATION.
+ (_file_header_information) <MathJax>: Move default MathJax
+ configuration here from _setup_output. Always output it.
+ Only output value of MATHJAX_CONFIGURATION if set.
+ * doc/texinfo.texi (MathJax Customization Variables): update.
+ do not show default texi2any configuration of MathJax.
+
2024-10-13 Patrice Dumas <pertusus@free.fr>
* info/util.c (printed_representation): add a comment to explain tab
diff --git a/doc/texinfo.texi b/doc/texinfo.texi
index a2aaff5e23..4a4c8c9cab 100644
--- a/doc/texinfo.texi
+++ b/doc/texinfo.texi
@@ -18733,26 +18733,31 @@ is set to @samp{mathjax}.
@vtable @code
@item MATHJAX_CONFIGURATION
-Global @samp{MathJax} object configuration (inside the object braces).
-If @code{undef}, @command{texi2any} provides a defaults, which could be,
-for example:
-@example
- options: @{
- skipHtmlTags: @{'[-]': ['pre']@}, // do not skip pre
- ignoreHtmlClass: 'tex2jax_ignore',
- processHtmlClass: 'tex2jax_process'
- @},
- tex: @{
- processEscapes: false,
- processEnvironments: false,
- processRefs: false,
- displayMath: [
- ['\\[', '\\]']
- ],
- @},
-@end example
-
-If you provide different defaults, you should make sure that they align
+Data to add to the global @samp{MathJax} configuration object.
+Specify as a comma-separated list of
+@code{@var{component}: @{ @var{name}: @var{value}, @dots{} @}}
+pairs.
+
+For example, you could set @code{MATHJAX_CONFIGURATION} to
+
+@example
+options: @{ enableMenu: false @},
+loader: @{
+ load: [\'[tex]/physics\'],
+ versionWarnings: false
+@},
+tex: @{
+ packages: @{\'[+]\': [\'physics\']@}
+@}
+@end example
+
+@noindent to disable the MathJax right-click menu, and to load the
+MathJax @code{physics} extension.
+(See @uref{https://docs.mathjax.org/en/latest/options/index.html,
+Configuring MathJax} in the MathJax documentation.)
+
+If you override any of the defaults for this configuration output by
+@command{texi2any} you should make sure that your new settings align
with the HTML output produced by @command{texi2any}.
@item MATHJAX_SCRIPT
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index fa26027638..636c1674c7 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -11231,15 +11231,49 @@ sub _file_header_information($$;$)
and $self->get_conf('HTML_MATH') eq 'mathjax')
and ($self->get_file_information('mathjax', $filename))) {
my $mathjax_script = $self->get_conf('MATHJAX_SCRIPT');
- my $mathjax_configuration = $self->get_conf('MATHJAX_CONFIGURATION');
+
+ my $default_mathjax_configuration =
+" options: {
+ skipHtmlTags: {'[-]': ['pre']}, // do not skip pre
+ ignoreHtmlClass: 'tex2jax_ignore',
+ processHtmlClass: 'tex2jax_process'
+ },
+ tex: {
+ processEscapes: false, // do not use \\\$ to produce a literal dollar
sign
+ processEnvironments: false, // do not process \\begin{xxx}...\\end{xxx}
outside math mode
+ processRefs: false, // do not process \\ref{...} outside of math
mode
+ displayMath: [ // start/end delimiter pairs for display math
+ ['\\\\[', '\\\\]']
+ ],
+ },";
$extra_head .=
"<script type='text/javascript'>
MathJax = {
+$default_mathjax_configuration
+};
+";
+
+ my $mathjax_configuration = $self->get_conf('MATHJAX_CONFIGURATION');
+ if (defined($mathjax_configuration)) {
+ $extra_head .=
+"var MathJax_conf = {
$mathjax_configuration
};
-</script>"
-.'<script type="text/javascript" id="MathJax-script" async
+
+for (let component in MathJax_conf) {
+ if (!MathJax.hasOwnProperty(component)) {
+ MathJax[component] = MathJax_conf[component];
+ } else {
+ for (let field in MathJax_conf[component]) {
+ MathJax[component][field] = MathJax_conf[component][field];
+ }
+ }
+}
+";
+ }
+
+ $extra_head .= '</script><script type="text/javascript"
id="MathJax-script" async
src="'.$self->url_protect_url_text($mathjax_script).'">
</script>';
@@ -13030,25 +13064,7 @@ sub _setup_output($)
$mathjax_source =
'http://docs.mathjax.org/en/latest/web/hosting.html#getting-mathjax-via-git';
$self->set_conf('MATHJAX_SOURCE', $mathjax_source);
}
-
- my $mathjax_configuration = $self->get_conf('MATHJAX_CONFIGURATION');
- if (!defined($mathjax_configuration)) {
- $mathjax_configuration = " options: {
- skipHtmlTags: {'[-]': ['pre']}, // do not skip pre
- ignoreHtmlClass: 'tex2jax_ignore',
- processHtmlClass: 'tex2jax_process'
- },
- tex: {
- processEscapes: false, // do not use \\\$ to produce a literal dollar
sign
- processEnvironments: false, // do not process \\begin{xxx}...\\end{xxx}
outside math mode
- processRefs: false, // do not process \\ref{...} outside of math
mode
- displayMath: [ // start/end delimiter pairs for display math
- ['\\\\[', '\\\\]']
- ],
- },";
- $self->set_conf('MATHJAX_CONFIGURATION', $mathjax_configuration);
- }
- }
+ }
my $setup_status = $self->run_stage_handlers($self->{'stage_handlers'},
$self->{'document'}, 'setup');
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: Only put extra settings in MATHJAX_CONFIGURATION,
Gavin D. Smith <=