From ed2ab2e2b0eada8e4c4728f23adf96d55eba8172 Mon Sep 17 00:00:00 2001
From: Kolen Cheung <ickc@users.noreply.github.com>
Date: Thu, 13 Jan 2022 20:31:32 -0800
Subject: [PATCH] HTML template: load header-includes before math (#7833)

MathJax expect the config comes before loading the MathJax script.
This change of order allows one to config MathJax via header-includes,
which loads before the MathJax script.

This potentially is a breaking change.

However, the only kind math supported by pandoc that is configurable
seems to be katex, and according to src/Text/Pandoc/Writers/HTML.hs
the way it is configured is hard-coded (katex doesn't seem to offer
MathJax style config that is independent of loading katex.)
So it seems it is safe to change this order without breaking
others' documents.

c.f. #2750
---
 data/templates/default.html4 | 6 +++---
 data/templates/default.html5 | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/data/templates/default.html4 b/data/templates/default.html4
index 00f0bacbc..daef6adb2 100644
--- a/data/templates/default.html4
+++ b/data/templates/default.html4
@@ -23,12 +23,12 @@ $endif$
 $for(css)$
   <link rel="stylesheet" href="$css$" type="text/css" />
 $endfor$
-$if(math)$
-  $math$
-$endif$
 $for(header-includes)$
   $header-includes$
 $endfor$
+$if(math)$
+  $math$
+$endif$
 </head>
 <body>
 $for(include-before)$
diff --git a/data/templates/default.html5 b/data/templates/default.html5
index 5242f797f..dda7e8cb0 100644
--- a/data/templates/default.html5
+++ b/data/templates/default.html5
@@ -23,15 +23,15 @@ $endif$
 $for(css)$
   <link rel="stylesheet" href="$css$" />
 $endfor$
+$for(header-includes)$
+  $header-includes$
+$endfor$
 $if(math)$
   $math$
 $endif$
   <!--[if lt IE 9]>
     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
   <![endif]-->
-$for(header-includes)$
-  $header-includes$
-$endfor$
 </head>
 <body>
 $for(include-before)$