From 0287311bafc0bdd253df0c8d6df3ef85f804d263 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 6 Jun 2018 20:52:12 +0000
Subject: lwarp (6jun18)

git-svn-id: svn://tug.org/texlive/trunk@47944 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/lwarp/lwarp.sty | 1304 ++++++++++++++++-----------
 1 file changed, 759 insertions(+), 545 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/lwarp/lwarp.sty')

diff --git a/Master/texmf-dist/tex/latex/lwarp/lwarp.sty b/Master/texmf-dist/tex/latex/lwarp/lwarp.sty
index 6d24427a28d..15e1819cb54 100644
--- a/Master/texmf-dist/tex/latex/lwarp/lwarp.sty
+++ b/Master/texmf-dist/tex/latex/lwarp/lwarp.sty
@@ -17,7 +17,7 @@
 %% version 2005/12/01 or later.
 \NeedsTeXFormat{LaTeX2e}[1999/12/01]
 \ProvidesPackage{lwarp}
-    [2018/05/12 v0.56  Allows LaTeX to directly produce HTML5 output.]
+    [2018/06/06 v0.57  Allows LaTeX to directly produce HTML5 output.]
 
 
 
@@ -264,6 +264,7 @@ For a possible alternative, see package(s) #2.}
 \LWR@earlyloadnever{boxedminipage}{boxedminipage2e}
 \LWR@earlyloadnever{caption2}{caption}
 \LWR@earlyloadnever{fancyheadings}{fancyhdr}
+\LWR@earlyloadnever{glossary}{glossaries}
 \LWR@earlyloadnever{t1enc}{fontenc, inputenc, inputenx}
 \LWR@earlyloadnever{wasysym}{textcomp, amssymb, amsfonts, mnsymbol, fdsymbol}
 \LWR@loadafter{a4}
@@ -274,7 +275,10 @@ For a possible alternative, see package(s) #2.}
 \LWR@loadafter{acronym}
 \LWR@loadafter{adjmulticol}
 \LWR@loadafter{addlines}
+\LWR@loadafter{ae}
+\LWR@loadafter{aecc}
 \LWR@loadafter{afterpage}
+\LWR@loadafter{algorithm2e}
 \LWR@loadafter{algorithmicx}
 \LWR@loadafter{alltt}
 \LWR@loadafter{amsmath}
@@ -299,6 +303,8 @@ For a possible alternative, see package(s) #2.}
 \LWR@loadafter{bytefield}
 \LWR@loadafter{cancel}
 \LWR@loadafter{caption}
+\LWR@loadafter{caption2}
+\LWR@loadafter{ccaption}
 \LWR@loadafter{changebar}
 \LWR@notmemoirloadafter{changepage}
 \LWR@notmemoirloadafter{chngpage}
@@ -333,12 +339,14 @@ For a possible alternative, see package(s) #2.}
 \LWR@notmemoirloadafter{epigraph}
 \LWR@loadafter{epstopdf}
 \LWR@loadafter{epstopdf-base}
+\LWR@loadafter{errata}
 \LWR@loadafter{eso-pic}
 \LWR@loadafter{everypage}
 \LWR@loadafter{everyshi}
 \LWR@loadafter{extramarks}
 \LWR@loadafter{fancybox}
 \LWR@loadafter{fancyhdr}
+\LWR@loadafter{fancyheadings}
 \LWR@loadafter{fancyref}
 \LWR@loadafter{fancyvrb}
 \LWR@loadafter{figcaps}
@@ -368,6 +376,7 @@ For a possible alternative, see package(s) #2.}
 \LWR@loadafter{fwlw}
 \LWR@loadafter{geometry}
 \LWR@loadafter{glossaries}
+\LWR@loadafter{glossary}
 \LWR@loadafter{grffile}
 \LWR@loadafter{grid}
 \LWR@loadafter{gridset}
@@ -391,6 +400,7 @@ For a possible alternative, see package(s) #2.}
 \LWR@loadafter{listings}
 \LWR@loadafter{longtable}
 \LWR@loadafter{lscape}
+\LWR@loadafter{ltablex}
 \LWR@loadafter{ltcaption}
 \LWR@loadafter{ltxgrid}
 \LWR@loadafter{ltxtable}
@@ -446,6 +456,7 @@ For a possible alternative, see package(s) #2.}
 \LWR@loadafter{quoting}
 \LWR@loadafter{ragged2e}
 \LWR@loadafter{realscripts}
+\LWR@loadafter{register}
 \LWR@loadafter{relsize}
 \LWR@loadafter{resizegather}
 \LWR@loadafter{romanbar}
@@ -477,6 +488,7 @@ For a possible alternative, see package(s) #2.}
 \LWR@loadafter{subfig}
 \LWR@loadafter{subfigure}
 \LWR@loadafter{supertabular}
+\LWR@loadafter{t1inc}
 \LWR@loadafter{tabls}
 \LWR@notmemoirloadafter{tabularx}
 \LWR@loadafter{tabulary}
@@ -497,6 +509,7 @@ For a possible alternative, see package(s) #2.}
 \LWR@loadafter{todo}
 \LWR@loadafter{todonotes}
 \LWR@loadafter{transparent}
+\LWR@loadafter{trimclip}
 \LWR@loadafter{trivfloat}
 \LWR@loadafter{turnthepage}
 \LWR@loadafter{ulem}
@@ -507,14 +520,19 @@ For a possible alternative, see package(s) #2.}
 \LWR@notmemoirloadafter{verse}
 \LWR@loadafter{vertbars}
 \LWR@loadafter{vmargin}
+\LWR@loadafter{vowel}
 \LWR@loadafter{vwcol}
 \LWR@loadafter{wallpaper}
+\LWR@loadafter{wasysym}
 \LWR@loadafter{watermark}
 \LWR@loadafter{wrapfig}
 \LWR@loadafter{xcolor}
+\LWR@loadafter{xellipsis}
 \LWR@loadafter{xfrac}
+\LWR@loadafter{xltabular}
 \LWR@loadafter{xltxtra}
 \LWR@loadafter{xmpincl}
+\LWR@loadafter{xpiano}
 \LWR@loadafter{xtab}
 \LWR@loadafter{xurl}
 \LWR@loadafter{xy}
@@ -645,7 +663,7 @@ top=1in,bottom=1in,%
 
 \begin{warpHTML}
 
-\LetLtxMacro{\LWR@origRequirePackage}{\RequirePackage}
+\LetLtxMacro\LWR@origRequirePackage\RequirePackage
 
 \newcommand*{\LWR@requirepackagenames}{}
 
@@ -706,7 +724,7 @@ top=1in,bottom=1in,%
     {\LWR@origRequirePackage{\LWR@parsedrequirepackagenames}}%
 }%
 }
-\LetLtxMacro{\usepackage}{\RequirePackage}
+\LetLtxMacro\usepackage\RequirePackage
 
 \NewDocumentCommand{\LWR@ProvidesPackagePass}{m o}{
 \PackageInfo{lwarp}{Using package `#1' and adding lwarp modifications, including options,}%
@@ -830,7 +848,6 @@ top=1in,bottom=1in,%
 \ifbool{LWR@tracinglwarp}%
 {%
     \typeout{*** lwarp: #1}%
-    % \PackageInfo{lwarp}{#1 : }%
 }%
 {}%
 }
@@ -848,6 +865,63 @@ top=1in,bottom=1in,%
 
 \end{warpall}
 
+
+
+
+\begin{warpHTML}
+\newcommand*{\LWR@formatting}{HTML}
+\newcommand*{\LWR@formatted}[1]{%
+    \ifcsundef{LWR@print@#1}{%
+        \expandafter\LetLtxMacro\csname LWR@print@#1\expandafter\endcsname%
+            \csname#1\endcsname%
+    }{}%
+    \ifcsundef{#1}{%
+        \expandafter\newrobustcmd\csname #1\endcsname{%
+            \csuse{LWR@\LWR@formatting @#1}%
+        }%
+    }{%
+        \expandafter\renewrobustcmd\csname #1\endcsname{%
+            \csuse{LWR@\LWR@formatting @#1}%
+        }%
+    }%
+}
+\newcommand*{\LWR@expandableformatted}[1]{%
+    \ifcsundef{LWR@print@#1}{%
+        \expandafter\LetLtxMacro\csname LWR@print@#1\expandafter\endcsname%
+            \csname#1\endcsname%
+    }{}%
+    \ifcsundef{#1}{%
+        \expandafter\newcommand\csname #1\endcsname{%
+            \csuse{LWR@\LWR@formatting @#1}%
+        }%
+    }{%
+        \expandafter\renewcommand\csname #1\endcsname{%
+            \csuse{LWR@\LWR@formatting @#1}%
+        }%
+    }%
+}
+\newcommand*{\LWR@formattedenv}[1]{%
+    \ifcsundef{LWR@print@#1}{%
+        \expandafter\LetLtxMacro\csname LWR@print@#1\expandafter\endcsname%
+            \csname#1\endcsname%
+        \csletcs{endLWR@print@#1}{end#1}%
+    }{}%
+    \DeclareDocumentEnvironment{#1}{}%
+    {\csuse{LWR@\LWR@formatting @#1}}%
+    {\csuse{endLWR@\LWR@formatting @#1}}%
+}
+\newcommand*{\LWR@expandableformattedenv}[1]{%
+    \ifcsundef{LWR@print@#1}{%
+        \expandafter\LetLtxMacro\csname LWR@print@#1\expandafter\endcsname%
+            \csname#1\endcsname%
+        \csletcs{endLWR@print@#1}{end#1}%
+    }{}%
+    \DeclareExpandableDocumentEnvironment{#1}{}%
+    {\csuse{LWR@\LWR@formatting @#1}}%
+    {\csuse{endLWR@\LWR@formatting @#1}}%
+}
+\end{warpHTML}
+
 \begin{warpall}
 \newbool{FormatEPUB}
 \boolfalse{FormatEPUB}
@@ -939,8 +1013,6 @@ top=1in,bottom=1in,%
 
 \begin{warpHTML}
 
-\LetLtxMacro\LWR@origmbox\mbox
-\LetLtxMacro\LWR@origmakebox\makebox
 \chardef\LWR@origpound=`\#
 \let\LWR@origcomma\,
 \let\LWR@origthinspace\thinspace
@@ -948,17 +1020,13 @@ top=1in,bottom=1in,%
 \let\LWR@origenskip\enskip
 \let\LWR@origquad\quad
 \let\LWR@origqquad\qquad
-
-\let\LWR@orighspace\hspace
 \let\LWR@orighfill\hfill
 \let\LWR@orighfil\hfil
-\let\LWR@origvspace\vspace
 \let\LWR@orighss\hss
 \let\LWR@origllap\llap
 \let\LWR@origrlap\rlap
 \let\LWR@orighfilneg\hfilneg
 
-\let\LWR@origrule\rule
 \let\LWR@orighrulefill\hrulefill
 \let\LWR@origdotfill\dotfill
 
@@ -978,29 +1046,29 @@ top=1in,bottom=1in,%
 \let\LWR@orighuge\huge
 \let\LWR@origHuge\Huge
 
-\LetLtxMacro{\LWR@origtextrm}{\textrm}
-\LetLtxMacro{\LWR@origtextsf}{\textsf}
-\LetLtxMacro{\LWR@origtexttt}{\texttt}
-\LetLtxMacro{\LWR@origtextnormal}{\textnormal}
-\LetLtxMacro{\LWR@origtextbf}{\textbf}
-\LetLtxMacro{\LWR@origtextmd}{\textmd}
-\LetLtxMacro{\LWR@origtextit}{\textit}
-\LetLtxMacro{\LWR@origtextsl}{\textsl}
-\LetLtxMacro{\LWR@origtextsc}{\textsc}
-\LetLtxMacro{\LWR@origtextup}{\textup}
-\LetLtxMacro{\LWR@origemph}{\emph}
-
-\LetLtxMacro{\LWR@origrmfamily}{\rmfamily}
-\LetLtxMacro{\LWR@origsffamily}{\sffamily}
-\LetLtxMacro{\LWR@origttfamily}{\ttfamily}
-\LetLtxMacro{\LWR@origbfseries}{\bfseries}
-\LetLtxMacro{\LWR@origmdseries}{\mdseries}
-\LetLtxMacro{\LWR@origupshape}{\upshape}
-\LetLtxMacro{\LWR@origslshape}{\slshape}
-\LetLtxMacro{\LWR@origscshape}{\scshape}
-\LetLtxMacro{\LWR@origitshape}{\itshape}
-\LetLtxMacro{\LWR@origem}{\em}
-\LetLtxMacro{\LWR@orignormalfont}{\normalfont}
+\LetLtxMacro\LWR@origtextrm\textrm
+\LetLtxMacro\LWR@origtextsf\textsf
+\LetLtxMacro\LWR@origtexttt\texttt
+\LetLtxMacro\LWR@origtextnormal\textnormal
+\LetLtxMacro\LWR@origtextbf\textbf
+\LetLtxMacro\LWR@origtextmd\textmd
+\LetLtxMacro\LWR@origtextit\textit
+\LetLtxMacro\LWR@origtextsl\textsl
+\LetLtxMacro\LWR@origtextsc\textsc
+\LetLtxMacro\LWR@origtextup\textup
+\LetLtxMacro\LWR@origemph\emph
+
+\LetLtxMacro\LWR@origrmfamily\rmfamily
+\LetLtxMacro\LWR@origsffamily\sffamily
+\LetLtxMacro\LWR@origttfamily\ttfamily
+\LetLtxMacro\LWR@origbfseries\bfseries
+\LetLtxMacro\LWR@origmdseries\mdseries
+\LetLtxMacro\LWR@origupshape\upshape
+\LetLtxMacro\LWR@origslshape\slshape
+\LetLtxMacro\LWR@origscshape\scshape
+\LetLtxMacro\LWR@origitshape\itshape
+\LetLtxMacro\LWR@origem\em
+\LetLtxMacro\LWR@orignormalfont\normalfont
 
 \let\LWR@origraggedright\raggedright
 \let\LWR@origonecolumn\onecolumn
@@ -1025,10 +1093,6 @@ top=1in,bottom=1in,%
 \let\LWR@origthispagestyle\thispagestyle
 \LetLtxMacro\LWR@origpagenumbering\pagenumbering
 
-\LetLtxMacro\LWR@origminipage\minipage
-\let\LWR@origendminipage\endminipage
-\LetLtxMacro{\LWR@origparbox}{\parbox}
-
 \let\LWR@orignewline\newline
 
 \AtBeginDocument{% in case packages change definition
@@ -1051,7 +1115,7 @@ top=1in,bottom=1in,%
 
 \let\LWR@origpar\par
 
-\LetLtxMacro{\LWR@origfootnote}{\footnote}
+\LetLtxMacro\LWR@origfootnote\footnote
 \let\LWR@orig@mpfootnotetext\@mpfootnotetext
 
 \let\LWR@origclearpage\clearpage
@@ -1065,15 +1129,15 @@ top=1in,bottom=1in,%
 
 \begin{warpHTML}
 \AtBeginDocument{
-\LetLtxMacro{\LWR@origt}{\t}
+\LetLtxMacro\LWR@origt\t
 \ifPDFTeX
-\LetLtxMacro{\LWR@origequalaccent}{\=}
-\LetLtxMacro{\LWR@origdotaccent}{\.}
-\LetLtxMacro{\LWR@origu}{\u}
-\LetLtxMacro{\LWR@origv}{\v}
-\LetLtxMacro{\LWR@origc}{\c}
-\LetLtxMacro{\LWR@origd}{\d}
-\LetLtxMacro{\LWR@origb}{\b}
+\LetLtxMacro\LWR@origequalaccent\=
+\LetLtxMacro\LWR@origdotaccent\.
+\LetLtxMacro\LWR@origu\u
+\LetLtxMacro\LWR@origv\v
+\LetLtxMacro\LWR@origc\c
+\LetLtxMacro\LWR@origd\d
+\LetLtxMacro\LWR@origb\b
 \renewcommand*{\=}[1]{#1\HTMLunicode{0305}}
 \renewcommand*{\.}[1]{#1\HTMLunicode{0307}}
 \renewcommand*{\u}[1]{#1\HTMLunicode{0306}}
@@ -1086,18 +1150,18 @@ top=1in,bottom=1in,%
 \renewcommand*{\t}[1]{\LWR@t#1}
 \ifPDFTeX
 \newcommand*{\LWR@restoreorigaccents}{%
-\LetLtxMacro{\=}{\LWR@origequalaccent}%
-\LetLtxMacro{\.}{\LWR@origdotaccent}%
-\LetLtxMacro{\u}{\LWR@origu}%
-\LetLtxMacro{\v}{\LWR@origu}%
-\LetLtxMacro{\t}{\LWR@origt}%
-\LetLtxMacro{\c}{\LWR@origc}%
-\LetLtxMacro{\d}{\LWR@origd}%
-\LetLtxMacro{\b}{\LWR@origb}%
+\LetLtxMacro\=\LWR@origequalaccent%
+\LetLtxMacro\.\LWR@origdotaccent%
+\LetLtxMacro\u\LWR@origu%
+\LetLtxMacro\v\LWR@origu%
+\LetLtxMacro\t\LWR@origt%
+\LetLtxMacro\c\LWR@origc%
+\LetLtxMacro\d\LWR@origd%
+\LetLtxMacro\b\LWR@origb%
 }%
 \else% XeLaTeX, LuaLaTeX:
 \newcommand*{\LWR@restoreorigaccents}{%
-\LetLtxMacro{\t}{\LWR@origt}%
+\LetLtxMacro\t\LWR@origt%
 }%
 \fi%
 }% AtBeginDocument
@@ -1973,7 +2037,7 @@ img.logoimage{
 }
 
 figure {
-    margin: 3ex auto 3ex auto ;
+    margin: 5ex auto 5ex auto ;
     padding: 1ex 1em 1ex 1em ;
     overflow-x: auto ;
 }
@@ -2036,6 +2100,27 @@ figure div.floatrow div.minipage figcaption {
     background: none ;
 }
 
+/* For packages such as float, rotfloat, and algorithm2e: */
+
+figure.boxed, figure.boxruled {
+    border: 1px solid black ;
+}
+
+figure.ruled {
+    border-top: 1px solid black ;
+    border-bottom: 1px solid black ;
+    border-left: 0px ;
+    border-right: 0px ;
+    border-radius: 0px ;
+    background: none ;
+    box-shadow: none ;
+}
+
+figure.ruled figcaption, figure.boxruled figcaption {
+    border-top: 1px solid silver ;
+    border-bottom: 1px solid silver ;
+}
+
 table {
     margin: 1ex auto 1ex auto ;
     border-collapse: separate ;
@@ -2315,7 +2400,32 @@ div.multicols { -webkit-columns: 3 380px ;
     -moz-columns: 3 380px ; columns: 3 380px ; }
 div.multicols p {margin-top: 0ex}
 
-/* Used to support algorithmicx: */
+/* Used for algorithm2e: */
+div.alg2evline{
+    margin-left: 1em ;
+    padding-left: 1em ;
+    border-left: 1px solid black ;
+    border-radius: 0px 0px 0px 1ex ;
+}
+
+div.alg2evsline{
+    margin-left: 1em ;
+    padding-left: 1em ;
+    border-left: 1px solid black ;
+}
+
+div.alg2enoline{
+    margin-left: 1em ;
+    padding-left: 1em ;
+}
+
+span.alg2elinenumber{
+    margin-right: .5em ;
+    font-size: 50% ;
+    color: red ;
+}
+
+/* Used for algorithmicx: */
 span.floatright { float: right ; }
 
 /* Native LaTeX theorems: */
@@ -2880,7 +2990,7 @@ div.fancyvrblabel{
 }
 
 figure {
-    margin: 3ex 5% 3ex 5% ;
+    margin: 5ex 5% 5ex 5% ;
     padding: 1ex 1em 1ex 1em ;
     background-color: #fffcf5 ;
     overflow-x: auto ;
@@ -3117,15 +3227,16 @@ src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-
 
 -- Copyright 2016-2018 Brian Dunn
 
--- Print the usage of the lwarpmk command:
-
-printversion = "v0.56"
+printversion = "v0.57"
 
 function printhelp ()
 print ("lwarpmk: Use lwarpmk -h or lwarpmk --help for help.") ;
 end
 
 function printusage ()
+--
+-- Print the usage of the lwarpmk command:
+--
 print ( [[
 
 lwarpmk print [project]: Compile the print version if necessary.
@@ -3153,9 +3264,10 @@ lwarpmk --help: Print this help message.
 printconf ()
 end
 
--- Print the format of the configuration file lwarpmk.conf:
-
 function printconf ()
+--
+-- Print the format of the configuration file lwarpmk.conf:
+--
 print ( [[
 An example lwarpmk.conf or <project>.lwarpmkconf project file:
 --
@@ -3177,11 +3289,12 @@ Values must be in upright "quotes".
 ]] ) ;
 end
 
+function splitfile (destfile,sourcefile)
+--
 -- Split one large sourcefile into a number of files,
 -- starting with destfile.
 -- The file is split at each occurance of <!--|Start file|newfilename|*
-
-function splitfile (destfile,sourcefile)
+--
 print ("lwarpmk: Splitting " .. sourcefile .. " into " .. destfile) ;
 local sfile = io.open(sourcefile)
 io.output(destfile)
@@ -3198,20 +3311,25 @@ end -- do
 io.close(sfile)
 end -- function
 
--- Incorrect value, so print an error and exit.
-
 function cvalueerror ( line, linenum , cvalue )
+--
+-- Incorrect value, so print an error and exit.
+--
     print ("lwarpmk: ===")
     print ("lwarpmk: " .. linenum .. " : " .. line ) ;
-    print ("lwarpmk: incorrect variable value \"" .. cvalue .. "\" in lwarpmk.conf.\n" ) ;
+    print (
+        "lwarpmk: incorrect variable value \"" .. cvalue ..
+        "\" in lwarpmk.conf.\n"
+    ) ;
     print ("lwarpmk: ===")
     printconf () ;
     os.exit(1) ;
 end
 
--- Load settings from the project's "lwarpmk.conf" file:
-
 function loadconf ()
+--
+-- Load settings from the project's "lwarpmk.conf" file:
+--
 -- Default configuration filename:
 local conffile = "lwarpmk.conf"
 -- Optional configuration filename:
@@ -3233,7 +3351,10 @@ if (lfs.attributes(conffile,"mode")==nil) then
     print ("lwarpmk: recompile using pdflatex, xelatex, or lualatex,")
     print ("lwarpmk: then try using lwarpmk again.")
     if ( arg[2] ~= nil ) then
-        print ("lwarpmk: (\"" .. arg[2] .. "\" does not appear to be a project name.)")
+        print (
+            "lwarpmk: (\"" .. arg[2] ..
+            "\" does not appear to be a project name.)"
+        )
     end
     print ("lwarpmk: ===")
     printhelp () ;
@@ -3286,7 +3407,10 @@ elseif ( cvarname == "pdftotextenc" ) then pdftotextenc = cvalue
 else
     print ("lwarpmk: ===")
     print ("lwarpmk: " .. linenum .. " : " .. line ) ;
-    print ("lwarpmk: Incorrect variable name \"" .. cvarname .. "\" in " .. conffile ..".\n" ) ;
+    print (
+        "lwarpmk: Incorrect variable name \"" .. cvarname .. "\" in " ..
+        conffile ..".\n"
+    ) ;
     print ("lwarpmk: ===")
     printconf () ;
 os.exit(1) ;
@@ -3318,7 +3442,7 @@ if opsystem=="Unix" then  -- For Unix / Linux / Mac OS:
     opquote= "\'"
     cmdgroupopenname = " ( "
     cmdgroupclosename = " ) "
-    seqname = " ; "
+    seqname = " && "
     bgname = " &"
 elseif opsystem=="Windows" then -- For Windows
     rmname = "DEL"
@@ -3347,15 +3471,31 @@ end
 
 end -- loadconf
 
+function executecheckerror ( executecommands , errormessage )
+--
+-- Execute an operating system call,
+-- and maybe exit with an error message.
+--
+local err
+err = os.execute ( executecommands )
+if ( err ~= 0 ) then
+    print ("lwarpmk: ===")
+    print ("lwarpmk: " .. errormessage )
+    print ("lwarpmk: ===")
+    os.exit(1)
+end
+end -- executecheckerror
+
 function refreshdate ()
 os.execute(touchnamepre .. " " .. sourcename .. ".tex " .. touchnamepost)
 end
 
+function reruntoget (filesource)
+--
 -- Scan the LaTeX log file for the phrase "Rerun to get",
 -- indicating that the file should be compiled again.
 -- Return true if found.
-
-function reruntoget (filesource)
+--
 local fsource = io.open(filesource)
 for line in fsource:lines() do
 if ( string.find(line,"Rerun to get") ~= nil ) then
@@ -3367,10 +3507,11 @@ io.close(fsource)
 return false
 end
 
+function onetime (fsuffix)
+--
 -- Compile one time, return true if should compile again.
 -- fsuffix is "" for print, "_html" for HTML output.
-
-function onetime (fsuffix)
+--
 print("lwarpmk: Compiling with " .. latexname .. " " .. sourcename..fsuffix)
 local thisshellescape = " "
 if ( shellescape == "true" ) then
@@ -3378,20 +3519,18 @@ if ( shellescape == "true" ) then
 else
     thisshellescape = " "
 end
-err = os.execute(latexname .. thisshellescape .. sourcename..fsuffix)
-if ( err ~= 0 ) then
-    print ("lwarpmk: ===")
-    print ("lwarpmk: Compile error.")
-    print ("lwarpmk: ===")
-    os.exit(1)
-end
+executecheckerror (
+    latexname .. thisshellescape .. sourcename..fsuffix ,
+    "Compile error."
+)
 return (reruntoget(sourcename .. fsuffix .. ".log") ) ;
 end
 
+function manytimes (fsuffix)
+--
 -- Compile up to five times.
 -- fsuffix is "" for print, "_html" for HTML output
-
-function manytimes (fsuffix)
+--
 if onetime(fsuffix) == true then
 if onetime(fsuffix) == true then
 if onetime(fsuffix) == true then
@@ -3400,9 +3539,10 @@ if onetime(fsuffix) == true then
 end end end end end
 end
 
--- Exit if the given file does not exist.
-
 function verifyfileexists (filename)
+--
+-- Exit if the given file does not exist.
+--
 if (lfs.attributes ( filename , "modification" ) == nil ) then
     print ("lwarpmk: ===")
     print ("lwarpmk: " .. filename .. " not found." ) ;
@@ -3411,9 +3551,10 @@ if (lfs.attributes ( filename , "modification" ) == nil ) then
 end
 end
 
--- Convert <project>_html.pdf into HTML files:
-
 function pdftohtml ()
+--
+-- Convert <project>_html.pdf into HTML files:
+--
 -- Convert to text:
 print ("lwarpmk: Converting " .. sourcename
     .."_html.pdf to " .. sourcename .. "_html.html")
@@ -3423,9 +3564,11 @@ os.execute("pdftotext  -enc " .. pdftotextenc .. "  -nopgbrk  -layout "
 splitfile (homehtmlfilename .. ".html" , sourcename .. "_html.html")
 end
 
+function removeaux ()
+--
 -- Remove auxiliary files:
 -- All aux files are removed since there may be many bbl*.aux files.
-function removeaux ()
+--
 os.execute ( rmname .. " *.aux " ..
     sourcename ..".toc " .. sourcename .. "_html.toc " ..
     sourcename ..".lof " .. sourcename .. "_html.lof " ..
@@ -3438,10 +3581,12 @@ os.execute ( rmname .. " *.aux " ..
     )
 end
 
+function checkhtmlpdfexists ()
+--
 -- Error if the HTML document does not exist.
--- The lateximages are drawn from the HTML PDF verison of the document,
+-- The lateximages are drawn from the HTML PDF version of the document,
 -- so "lwarpmk html" must be done before "lwarpmk limages".
-function checkhtmlpdfexists ()
+--
 local htmlpdffile = io.open(sourcename .. "_html.pdf", "r")
 if ( htmlpdffile == nil ) then
     print ("")
@@ -3454,8 +3599,10 @@ end
 io.close (htmlpdffile)
 end -- checkhtmlpdfexists
 
--- Warning of a missing lateximages.txt file:
 function warnlimages ()
+--
+-- Warning of a missing lateximages.txt file:
+--
     print ("lwarpmk: ===")
     print ("lwarpmk: \"lateximages.txt\" does not exist.")
     print ("lwarpmk: Your project does not use SVG math or other lateximages,")
@@ -3468,9 +3615,11 @@ function warnlimages ()
     print ("lwarpmk: ===")
 end -- warnlimages
 
+function checklimages ()
+--
 -- Check lateximages.txt to see if need to recompile first.
 -- If any entry has a page number of zero, then there were incorrect images.
-function checklimages ()
+--
 print ("lwarpmk: Checking for a valid lateximages.txt file.")
 local limagesfile = io.open("lateximages.txt", "r")
 if ( limagesfile == nil ) then
@@ -3502,90 +3651,33 @@ if ( pagezerowarning ) then
     print ("lwarpmk: ===")
     os.exit(1) ;
 end -- pagezerowarning
-end -- checklateximages
+end -- checklimages
 
--- Create lateximages based on lateximages.txt:
-function createlateximages ()
--- See if the document must be recompiled first:
-checklimages ()
--- See if the print version exists:
-checkhtmlpdfexists ()
--- Attempt to create the lateximages:
-print ("lwarpmk: Creating lateximages.")
-local limagesfile = io.open("lateximages.txt", "r")
-if ( limagesfile == nil ) then
-    warnlateximages ()
-    os.exit(1)
-end
--- Create the lateximages directory, ignore error if already exists
-err = os.execute("mkdir lateximages")
--- For Windows, create lwarp_one_limage.cmd from lwarp_one_limage.txt:
-if opsystem=="Windows" then
-    err = os.execute (
-        cpname .. " lwarp_one_limage.txt lwarp_one_limage.cmd"
-    )
-    if ( err ~= 0 ) then
-        print ("lwarpmk: ===")
-        print ("lwarpmk: File error trying to copy")
-        print ("         lwarp_one_limage.txt to lwarp_one_limage.cmd")
-        print ("lwarpmk: ===")
-        os.exit(1) ;
-    end
-end -- create lwarp_one_limage.cmd
--- Track the number of parallel processes
-numimageprocesses = 0
--- Track warning to recompile if find a page 0
-pagezerowarning = false
--- Scan lateximages.txt
-for line in limagesfile:lines() do
--- lwimgpage is the page number in the PDF which has the image
--- lwimghash is true if this filename is a hash
--- lwimgname is the lateximage filename root to assign for the image
-i,j,lwimgpage,lwimghash,lwimgname = string.find (line,"|(.*)|(.*)|(.*)|")
--- For each entry:
-if ( (i~=nil) ) then
--- Skip if the page number is 0:
-if ( lwimgpage == "0" ) then
-    pagezerowarning = true
-else
--- Skip is this image is hashed and already exists:
-local lwimgfullname = "lateximages" .. dirslash .. lwimgname .. ".svg"
-if (
-    (lwimghash ~= "true") or
-    (lfs.attributes(lwimgfullname,"mode")==nil) -- file not exists
-)
-then -- not hashed or not exists:
--- Print the name of the file being generated:
-print ( "lwarpmk: " .. lwimgname )
--- Touch/create the dest so that only once instance tries to build it:
-err = os.execute(newtouchname .. " " .. lwimgfullname)
-if ( err ~= 0 ) then
-    print ("lwarpmk: ===")
-    print ("lwarpmk: File error trying to touch " .. lwimgfullname)
-    print ("lwarpmk: ===")
-    os.exit(1) ;
-end
--- Separate out the image into its own single-page pdf:
-if opsystem=="Unix" then
--- For Unix / Linux / Mac OS:
-err = os.execute(
-cmdgroupopenname ..
-"pdfseparate -f " .. lwimgpage .. " -l " .. lwimgpage .. " " ..
-    sourcename .."_html.pdf " ..
-    "lateximages" .. dirslash .."lateximagetemp-%d" .. ".pdf" ..
-    seqname ..
--- Crop the image:
-"pdfcrop  --hires  lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf " ..
-    "lateximages" .. dirslash .. lwimgname .. ".pdf" ..
-    seqname ..
--- Convert the image to svg:
-"pdftocairo -svg  -noshrink  lateximages" .. dirslash .. lwimgname .. ".pdf " ..
-    "lateximages" .. dirslash .. lwimgname ..".svg" ..
-    seqname ..
--- Remove the temporary files:
-rmname .. " lateximages" .. dirslash .. lwimgname .. ".pdf" .. seqname ..
-rmname .. " lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf" ..
-cmdgroupclosename .. " >/dev/null " .. bgname
+function createuniximage ( lwimgfullname )
+--
+-- Create one lateximage for Unix / Linux / Mac OS.
+--
+executecheckerror (
+    cmdgroupopenname ..
+    "pdfseparate -f " .. lwimgpage .. " -l " .. lwimgpage .. " " ..
+        sourcename .."_html.pdf " ..
+        "lateximages" .. dirslash .."lateximagetemp-%d" .. ".pdf" ..
+        seqname ..
+    -- Crop the image:
+    "pdfcrop  --hires  lateximages" .. dirslash .. "lateximagetemp-" ..
+        lwimgpage .. ".pdf " ..
+        "lateximages" .. dirslash .. lwimgname .. ".pdf" ..
+        seqname ..
+    -- Convert the image to svg:
+    "pdftocairo -svg  -noshrink  lateximages" .. dirslash .. lwimgname .. ".pdf " ..
+        "lateximages" .. dirslash .. lwimgname ..".svg" ..
+        seqname ..
+    -- Remove the temporary files:
+    rmname .. " lateximages" .. dirslash .. lwimgname .. ".pdf" .. seqname ..
+    rmname .. " lateximages" .. dirslash .. "lateximagetemp-" .. lwimgpage .. ".pdf" ..
+    cmdgroupclosename .. " >/dev/null " .. bgname
+    ,
+    "File error trying to convert " .. lwimgfullname
 )
 -- Every 32 images, wait for completion at below normal priority,
 --  allowing other image tasks to catch up.
@@ -3593,10 +3685,14 @@ numimageprocesses = numimageprocesses + 1
 if ( numimageprocesses > 32 ) then
     numimageprocesses = 0
     print ( "lwarpmk: waiting" )
-    err = os.execute ( "wait" )
+    executecheckerror ( "wait" , "File error trying to wait.")
 end
-elseif opsystem=="Windows" then
--- For Windows
+end -- createuniximage
+
+function createwindowsimage ( lwimgfullname )
+--
+-- Create one lateximage for Windows.
+--
 -- Every 32 images, wait for completion at below normal priority,
 --  allowing other image tasks to catch up.
 numimageprocesses = numimageprocesses + 1
@@ -3608,30 +3704,94 @@ else
     thiswaitcommand = ""
 end
 -- Execute the image generation command
-err = os.execute (
+executecheckerror (
     "start /B " .. thiswaitcommand .. " \"\" lwarp_one_limage " ..
     lwimgpage .. " " ..
     lwimghash .. " " ..
     lwimgname .. " " ..
     sourcename .. " <nul >nul"
+    ,
+    "File error trying to create image."
 )
-end -- Windows
-if ( err ~= 0 ) then
-    print ("lwarpmk: ===")
-    print ("lwarpmk: File error trying to create one lateximage.")
-    print ("lwarpmk: ===")
+end -- createwindowsimage
+
+function createonelateximage ( line )
+--
+-- Given the next line of lateximages.txt, convert a single image.
+--
+-- lwimgpage is the page number in the PDF which has the image
+-- lwimghash is true if this filename is a hash
+-- lwimgname is the lateximage filename root to assign for the image
+i,j,lwimgpage,lwimghash,lwimgname = string.find (line,"|(.*)|(.*)|(.*)|")
+-- For each entry:
+if ( (i~=nil) ) then
+    -- Skip if the page number is 0:
+    if ( lwimgpage == "0" ) then
+        pagezerowarning = true
+    else
+        -- Skip is this image is hashed and already exists:
+        local lwimgfullname = "lateximages" .. dirslash .. lwimgname .. ".svg"
+        if (
+            (lwimghash ~= "true") or
+            (lfs.attributes(lwimgfullname,"mode")==nil) -- file not exists
+        )
+        then -- not hashed or not exists:
+            -- Print the name of the file being generated:
+            print ( "lwarpmk: " .. lwimgname )
+            -- Touch/create the dest so that only once instance tries to build it:
+            executecheckerror (
+                newtouchname .. " " .. lwimgfullname ,
+                "File error trying to touch " .. lwimgfullname
+            )
+            -- Separate out the image into its own single-page pdf:
+            if opsystem=="Unix" then
+                createuniximage (lwimgfullname)
+            elseif opsystem=="Windows" then
+                createwindowsimage (lwimgfullname)
+            end
+        end -- not hashed or not exists
+    end -- not page 0
+end -- not nil
+end -- createonelateximage
+
+function createlateximages ()
+--
+-- Create lateximages based on lateximages.txt:
+--
+-- See if the document must be recompiled first:
+checklimages ()
+-- See if the print version exists:
+checkhtmlpdfexists ()
+-- Attempt to create the lateximages:
+print ("lwarpmk: Creating lateximages.")
+local limagesfile = io.open("lateximages.txt", "r")
+if ( limagesfile == nil ) then
+    warnlateximages ()
     os.exit(1)
 end
-end -- not hashed or not exists
-end -- not page 0
-end -- not nil
+-- Create the lateximages directory, ignore error if already exists
+err = os.execute("mkdir lateximages")
+-- For Windows, create lwarp_one_limage.cmd from lwarp_one_limage.txt:
+if opsystem=="Windows" then
+    executecheckerror (
+        cpname .. " lwarp_one_limage.txt lwarp_one_limage.cmd" ,
+        "File error trying to copy lwarp_one_limage.txt to lwarp_one_limage.cmd"
+    )
+end -- create lwarp_one_limage.cmd
+-- Track the number of parallel processes
+numimageprocesses = 0
+-- Track warning to recompile if find a page 0
+pagezerowarning = false
+-- Scan lateximages.txt
+for line in limagesfile:lines() do
+    createonelateximage ( line )
 end -- do
 io.close(limagesfile)
 print ( "lwarpmk limages: ===")
 print ( "lwarpmk limages: Wait a moment for the images to complete" )
-print ( "lwarpmk limages: before reloading the page." )
+print ( "lwarpmk limages:   before reloading the page." )
 print ( "lwarpmk limages: ===")
-print ( "lwarpmk limages: done" )
+print ( "lwarpmk limages: Done." )
 if ( pagezerowarning == true ) then
     print ( "lwarpmk limages: WARNING: Images will be incorrect." )
     print ( "lwarpmk limages:   Enter \"lwarpmk cleanlimages\", then" )
@@ -3640,9 +3800,11 @@ if ( pagezerowarning == true ) then
 end -- pagezerowarning
 end -- function
 
+function compilelatexmk ( fsuffix )
+--
 -- Use latexmk to compile source and index:
 -- fsuffix is "" for print, or "_html" for HTML
-function compilelatexmk ( fsuffix )
+--
 -- Maybe select the shell-escape option:
 local thisshellescape = " "
 if ( shellescape == "true" ) then
@@ -3652,7 +3814,8 @@ else
 end
 -- The recorder option is required to detect changes in <project>.tex
 -- while we are loading <project>_html.tex.
-err=os.execute ( "latexmk -pdf -dvi- -ps- -recorder "
+executecheckerror (
+    "latexmk -pdf -dvi- -ps- -recorder "
     .. "-e "
     .. opquote
     .. "$makeindex = q/" -- $
@@ -3662,19 +3825,18 @@ err=os.execute ( "latexmk -pdf -dvi- -ps- -recorder "
     .. "  -L " .. xindylanguage .. " /"
     .. opquote
     .. " -pdflatex=\"" .. latexname .. thisshellescape .." %O %S\" "
-    .. sourcename..fsuffix ..".tex" ) ;
-if ( err ~= 0 ) then
-    print ("lwarpmk: ===")
-    print ("lwarpmk: Compile error.")
-    print ("lwarpmk: ===")
-    os.exit(1)
-end
+    .. sourcename..fsuffix ..".tex"
+    ,
+    "Compile error."
+)
 end -- function
 
+function convertpdftosvg ()
+--
 -- Converts PDF files to SVG files.
 -- The filenames are arg[2] and up.
 -- arg[1] is the command "pdftosvg".
-function convertpdftosvg ()
+--
 for i = 2 , #arg do
     if (lfs.attributes(arg[i],"mode")==nil) then
         print ("lwarpmk: File \"" .. arg[i] .. "\" does not exist.")
@@ -3685,6 +3847,8 @@ for i = 2 , #arg do
 end -- do
 end --function
 
+-- Start of the main code: --
+
 -- lwarpmk --version :
 
 if (arg[1] == "--version") then
@@ -3721,6 +3885,8 @@ else -- not latexmk
     end
 end -- not latexmk
 
+-- lwarpmk print1:
+
 elseif arg[1] == "print1" then
     loadconf ()
     verifyfileexists (sourcename .. ".tex") ;
@@ -3791,6 +3957,8 @@ else -- not latexmk
     end
 end -- not latexmk
 
+-- lwarpmk html1:
+
 elseif arg[1] == "html1" then
     loadconf ()
     verifyfileexists ( sourcename .. ".tex" ) ;
@@ -3798,6 +3966,7 @@ elseif arg[1] == "html1" then
     pdftohtml ()
     print ("lwarpmk: Done.")
 
+-- lwarpmk pdftohtml:
 elseif arg[1] == "pdftohtml" then
     loadconf ()
     pdftohtml ()
@@ -3905,6 +4074,8 @@ printhelp ()
 elseif (arg[1] == "-h" ) or (arg[1] == "--help") then
 printusage ()
 
+-- Unknown command:
+
 else
 printhelp ()
 print ("\nlwarpmk: ****** Unknown command \""..arg[1].."\". ******\n")
@@ -4030,6 +4201,43 @@ end -- not --version
 
 \end{warpHTML}
 
+\begin{warpall}
+\newcommand{\StartDefiningTabulars}{%
+\LWR@traceinfo{StartDefiningTabulars}%
+\warpHTMLonly{\catcode`\&=\active}%
+}
+\newcommand{\StopDefiningTabulars}{%
+\LWR@traceinfo{StopDefiningTabulars}%
+\warpHTMLonly{\catcode`\&=4}%
+}
+
+\newbool{LWR@mathmacro}
+\boolfalse{LWR@mathmacro}
+
+\newcommand{\StartDefiningMath}{%
+\LWR@traceinfo{StartDefiningMath}%
+\warpHTMLonly{\catcode`\$=\active}%
+}
+\newcommand{\StopDefiningMath}{%
+\LWR@traceinfo{StopDefiningMath}%
+\warpHTMLonly{\catcode`\$=3}% math shift
+}
+
+\end{warpall}
+
+\begin{warpall}
+\newbool{LWR@dynamicmath}
+\boolfalse{LWR@dynamicmath}
+\newcommand{\StartDynamicMath}{%
+\LWR@traceinfo{StartDynamicMath}%
+\booltrue{LWR@dynamicmath}%
+}
+\newcommand{\StopDynamicMath}{%
+\LWR@traceinfo{StopDynamicMath}%
+\boolfalse{LWR@dynamicmath}%
+}
+\end{warpall}
+
 
 \begin{warpHTML}
 
@@ -4138,9 +4346,7 @@ end -- not --version
 \begin{warpHTML}
 
 \newcommand*{\LinkHome}{%
-\LWR@subhyperrefclass{%
-\HomeHTMLFilename.html}%
-{Home}{linkhome}%
+\LWR@subhyperrefclass{\HomeHTMLFilename.html}{Home}{linkhome}%
 }
 
 \newcommand*{\LWR@topnavigation}{
@@ -4376,7 +4582,7 @@ end -- not --version
 \begingroup%
 \LWR@FBcancel%
 \ifmmode\else\protect\LWR@origttfamily\fi%
-\LWR@origmbox{\LWR@origtextless{}!{-}{-}}%
+\LWR@print@mbox{\LWR@origtextless{}!{-}{-}}%
 \endgroup%
 }%
 }
@@ -4386,7 +4592,7 @@ end -- not --version
 \begingroup%
 \LWR@FBcancel%
 \ifmmode\else\protect\LWR@origttfamily\fi%
-\LWR@origmbox{{-}{-}\LWR@origtextgreater}%
+\LWR@print@mbox{{-}{-}\LWR@origtextgreater}%
 \endgroup%
 }%
 }
@@ -4463,38 +4669,51 @@ end -- not --version
 \end{warpHTML}
 
 
+\begin{warpprint}
+\NewDocumentEnvironment{BlockClass}{o m}{}{}%
+\end{warpprint}
 \begin{warpHTML}
-\NewDocumentEnvironment{BlockClass}{o m}%
+\NewDocumentEnvironment{LWR@print@BlockClass}{o m}{}{}%
+\NewDocumentEnvironment{LWR@HTML@BlockClass}{o m}%
 {%
     \LWR@origpar%
     \LWR@htmldivclass[#1]{#2}%
 }
 {\LWR@htmldivclassend{#2}}
+
+\LWR@formattedenv{BlockClass}
 \end{warpHTML}
-\begin{warpprint}
-\NewDocumentEnvironment{BlockClass}{o m}{}{}%
-\end{warpprint}
+\begin{warpall}
+\newcommand{\BlockClassSingle}[2]{#2}
+\end{warpall}
 \begin{warpHTML}
-\newcommand{\BlockClassSingle}[2]{%
+\newcommand{\LWR@HTML@BlockClassSingle}[2]{%
 \LWR@origpar%
 \LWR@htmlelementclassline{div}{#1}{#2}%
 }
+
+\LWR@formatted{BlockClassSingle}
 \end{warpHTML}
+
 \begin{warpprint}
-\newcommand{\BlockClassSingle}[2]{#2}
+\NewDocumentCommand{\InlineClass}{o m +m}{#3}%
 \end{warpprint}
-
 \begin{warpHTML}
-\NewDocumentCommand{\InlineClass}{o m +m}{%
-\LWR@htmlspanclass[#1]{#2}{#3}%
+\NewDocumentCommand{\LWR@print@InlineClass}{o m +m}{#3}%
+
+\NewDocumentCommand{\LWR@HTML@InlineClass}{o m +m}{%
+    \LWR@htmlspanclass[#1]{#2}{#3}%
 }
+
+\LWR@formatted{InlineClass}
 \end{warpHTML}
+
 \begin{warpprint}
-\NewDocumentCommand{\InlineClass}{o m +m}{#3}%
+\NewDocumentEnvironment{LWR@BlockClassWP}{m m m}{}{}%
 \end{warpprint}
-
 \begin{warpHTML}
-\NewDocumentEnvironment{LWR@BlockClassWP}{m m m}%
+\NewDocumentEnvironment{LWR@print@LWR@BlockClassWP}{m m m}{}{}%
+\NewDocumentEnvironment{LWR@HTML@LWR@BlockClassWP}{m m m}%
 {%
 \LWR@stoppars%
 \ifbool{FormatWP}%
@@ -4502,7 +4721,7 @@ end -- not --version
     \addtocounter{LWR@thisautoidWP}{1}%
     \LWR@htmltag{%
         div class="#3" %
-        id="\LWR@origmbox{autoidWP-\arabic{LWR@thisautoidWP}}"%
+        id="\LWR@print@mbox{autoidWP-\arabic{LWR@thisautoidWP}}"%
         \ifblank{#1}{}{ style="#1"}%
     }%
 }% FormatWP
@@ -4515,10 +4734,9 @@ end -- not --version
 \LWR@startpars%
 }
 {\LWR@htmldivclassend{#3}}
+
+\LWR@formattedenv{LWR@BlockClassWP}
 \end{warpHTML}
-\begin{warpprint}
-\NewDocumentEnvironment{LWR@BlockClassWP}{m m m}{}{}%
-\end{warpprint}
 
 
 \begin{warpHTML}
@@ -4853,7 +5071,7 @@ end -- not --version
 \ifvoid\LWR@mpfootnotes\else
     \LWR@forcenewpage
     \begin{BlockClass}{footnotes}
-    \LWR@origvspace*{\baselineskip}
+    \LWR@print@vspace*{\baselineskip}
     \unvbox\LWR@mpfootnotes
     \setbox\LWR@mpfootnotes=\vbox{}
     \end{BlockClass}
@@ -5016,6 +5234,10 @@ end -- not --version
 
 \(\newcommand\ensuremath[1]{##1}\)
 
+\(\newcommand\footnote[2][]{\text{( Footnote ##1 )}}\)
+
+\(\newcommand\footnotemark[1][]{\text{( Footnote ##1 )}}\)
+
 \LWR@htmlcomment{Additional customizations for MathJax:}
 
 \LWR@customizedMathJax
@@ -5159,7 +5381,7 @@ end -- not --version
 }
 
 \newcommand*{\LWR@createautosec}[1]{%
-\LWR@htmltag{#1 id="\LWR@origmbox{autosec-\arabic{page}}"}%
+\LWR@htmltag{#1 id="\LWR@print@mbox{autosec-\arabic{page}}"}%
 }
 
 \NewDocumentCommand{\LWR@pushoneclose}{m m}{%
@@ -5513,10 +5735,10 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 \setlength{\belowcaptionskip}{0ex}
 \setlength{\abovecaptionskip}{0ex}
 \renewcommand{\ps@plain}{}
-\LetLtxMacro{\LWR@origtabular}{\tabular}
-\LetLtxMacro{\LWR@origendtabular}{\endtabular}
-\LetLtxMacro{\tabular}{\LWR@tabular}
-\LetLtxMacro{\endtabular}{\endLWR@tabular}
+\LetLtxMacro\LWR@origtabular\tabular
+\LetLtxMacro\LWR@origendtabular\endtabular
+\LetLtxMacro\tabular\LWR@tabular
+\LetLtxMacro\endtabular\endLWR@tabular
 \let\LWR@origcaption\caption
 \let\LWR@origltx@label\ltx@label
 \let\ltx@label\LWR@htmlmathlabel
@@ -5886,21 +6108,21 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
         \ifthenelse{\equal{#1}{}}{}{style="#1"}%
     }%
     \LWR@orignewline% pre
-    \leavevmode\unskip\LWR@origvspace*{-#2\baselineskip}%
+    \leavevmode\unskip\LWR@print@vspace*{-#2\baselineskip}%
 }{}%
 \begingroup%
 \LWR@origttfamily%
 \LWR@origsmall%
 \LWR@restoreoriglists%
 \LWR@FBcancel%
-\LetLtxMacro{\hspace}{\LWR@orighspace}%
+\LWR@select@print@hspace%
 }
 
 \newcommand*{\LWR@afterendverbatim}[1]{%
 \endgroup%
 \par%
 \ifbool{LWR@verbtags}{%
-    \LWR@origvspace*{-#1\baselineskip}%
+    \LWR@print@vspace*{-#1\baselineskip}%
     \noindent\LWR@htmltag{/pre}\LWR@orignewline% pre
 }{}%
 \LWR@startpars%
@@ -5974,7 +6196,7 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 
 \newcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
 
-\newcommand*{\LWR@printopenlist}{ul style="\LWR@origmbox{list-style-type:none}"}
+\newcommand*{\LWR@printopenlist}{ul style="\LWR@print@mbox{list-style-type:none}"}
 
 \AtBeginDocument{
 \def\@mklab#1{%
@@ -6070,7 +6292,7 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 
 \newcommand*{\LWR@itemizestart}{%
 \renewcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
-\renewcommand*{\LWR@printopenlist}{ul style="\LWR@origmbox{list-style-type:none}"}
+\renewcommand*{\LWR@printopenlist}{ul style="\LWR@print@mbox{list-style-type:none}"}
 \let\item\LWR@itemizeitem%
 \LWR@nulllistfills%
 }
@@ -6079,7 +6301,7 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 
 \newcommand*{\LWR@enumeratestart}{%
 \renewcommand*{\LWR@printcloselist}{\LWR@printcloseitemize}
-\renewcommand*{\LWR@printopenlist}{ul style="\LWR@origmbox{list-style-type:none}"}
+\renewcommand*{\LWR@printopenlist}{ul style="\LWR@print@mbox{list-style-type:none}"}
 \let\item\LWR@itemizeitem%
 \LWR@nulllistfills%
 }
@@ -6090,9 +6312,9 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 \LWR@stoppars%
 \LWR@setlatestname{#1}%
 \LWR@startnewdepth{\LWR@depthlistitem}{\LWR@printclosedescitem}%
-\LetLtxMacro\hspace\LWR@nohspace%
+\LWR@select@html@nohspace%
 \LWR@origitem[]%
-\LetLtxMacro\hspace\LWR@hspace%
+\LWR@select@html@hspace%
 \LWR@htmltag{dt}#1\LWR@htmltag{/dt}%
 \LWR@orignewline%
 \LWR@htmltag{dd}%
@@ -6289,19 +6511,7 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 \let\LWR@origampmacro&
 
 \end{warpHTML}
-\begin{warpall}
-\newcommand{\StartDefiningTabulars}{%
-\LWR@traceinfo{StartDefiningTabulars}%
-\warpHTMLonly{\catcode`\&=\active}%
-}
-\newcommand{\EndDefiningTabulars}{%
-\LWR@traceinfo{EndDefiningTabulars}%
-\warpHTMLonly{\catcode`\&=4}%
-}
-
-\end{warpall}
 \begin{warpHTML}
-
 \newcommand*{\LWR@tabularampersand}{%
 \LWR@traceinfo{LWR@tabularampersand}%
 \ifnumcomp{\value{LWR@tabulardepth}}{>}{0}%
@@ -6635,19 +6845,13 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 \newcommand*{\LWR@rowHTMLcolor}{}
 \newcommand*{\LWR@cellHTMLcolor}{}
 \newcommand*{\LWR@ruleHTMLcolor}{}
-\NewDocumentCommand{\LWR@HTMLcolumncolor}{O{named} m o o}{}
-
-\NewDocumentCommand{\LWR@HTMLrowcolor}{O{named} m o o}{\LWR@getmynexttoken}
-
-\NewDocumentCommand{\LWR@HTMLcellcolor}{O{named} m o o}{}
+\newcommand*{\rowcolor}{\LWR@getmynexttoken}%
 
 \newcommand{\arrayrulecolor}[2][named]{}
-
-\newcommand{\LWR@HTMLarrayrulecolor}[2][named]{\LWR@getmynexttoken}
+\newcommand{\arrayrulecolornexttoken}[2][named]{\LWR@getmynexttoken}
 
 \newcommand{\doublerulesepcolor}[2][named]{}
-
-\newcommand{\LWR@HTMLdoublerulesepcolor}[2][named]{\LWR@getmynexttoken}
+\newcommand{\doublerulesepcolornexttoken}[2][named]{\LWR@getmynexttoken}
 
 
 \newcommand*{\LWR@maybenewtablerow}
@@ -6962,7 +7166,7 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 
 \newcommand*{\LWR@WPcell}[2]{%
 \LWR@tdaddstyle%
-\LWR@origmbox{text-align:#1}; \LWR@origmbox{vertical-align:#2}%
+\LWR@print@mbox{text-align:#1}; \LWR@print@mbox{vertical-align:#2}%
 }
 
 \newcommand*{\LWR@addformatwpalignment}[1]{%
@@ -7298,8 +7502,8 @@ link rel="stylesheet" type="text/css" href="\LWR@currentcss" /}%
 \IfValueT{#2}{ % rows?
 rowspan="#2" %
 \IfValueT{#1}{% vpos?
-\ifstrequal{#1}{b}{style="\LWR@origmbox{vertical-align:bottom}" }{}%
-\ifstrequal{#1}{t}{style="\LWR@origmbox{vertical-align:top}" }{}%
+\ifstrequal{#1}{b}{style="\LWR@print@mbox{vertical-align:bottom}" }{}%
+\ifstrequal{#1}{t}{style="\LWR@print@mbox{vertical-align:top}" }{}%
 }% vpos?
 }% rows?
  class="td%
@@ -7374,7 +7578,8 @@ rowspan="#2" %
         {%
             \refstepcounter{\LTcaptype}%
             \protected@edef\@currentlabel{%
-            \csuse{p@\LTcaptype}\csuse{the\LTcaptype}}%
+                \csuse{p@\LTcaptype}\csuse{the\LTcaptype}%
+            }%
         }%
     }{}%
     \LWR@figcaption%
@@ -7450,31 +7655,41 @@ rowspan="#2" %
 }% whiledo
 }
 \end{warpHTML}
+\begin{warpHTML}
+\newcommand{\multirow}[2][c]{}
+\end{warpHTML}
 \begin{warpall}
 \AtBeginDocument{
 \@ifundefined{@xmultirow}
-{}% no version of multirow was loaded
+{
+\DeclareExpandableDocumentCommand{\LWR@print@multicolumnrow}%
+    {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
+    {}%
+}% no version of multirow was loaded
 {% \@xmultirow defined, so some version of multirow was loaded
 \@ifpackageloaded{multirow}{% v2.0 or newer
 \@ifpackagelater{multirow}{2016/09/01}% 2016/09/27 for v2.0
 {% v2.0+:
-\DeclareExpandableDocumentCommand{\LWR@origmulticolumnrow}%
+\DeclareExpandableDocumentCommand{\LWR@print@multicolumnrow}%
     {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
-{\multicolumn{#1}{#2}{\@xmultirow[#3]{#4}[#5]{#6}[#7]{#8}}}%
+    {\multicolumn{#1}{#2}{\@xmultirow[#3]{#4}[#5]{#6}[#7]{#8}}}%
 }
 {% loaded but older, probably not executed:
-\DeclareExpandableDocumentCommand{\LWR@origmulticolumnrow}%
+\DeclareExpandableDocumentCommand{\LWR@print@multicolumnrow}%
     {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
-{\multicolumn{#1}{#2}{\@xmultirow{#4}[#5]{#6}[#7]{#8}}}%
+    {\multicolumn{#1}{#2}{\@xmultirow{#4}[#5]{#6}[#7]{#8}}}%
 }
 }% packageloaded{multirow}
 {% v1.6 or older did not \ProvidePackage
-\DeclareExpandableDocumentCommand{\LWR@origmulticolumnrow}%
+\DeclareExpandableDocumentCommand{\LWR@print@multicolumnrow}%
     {+m +m +O{c} +m +O{0} +m +O{0pt} +m}%
-{\multicolumn{#1}{#2}{\@xmultirow{#4}[#5]{#6}[#7]{#8}}}%
+    {\multicolumn{#1}{#2}{\@xmultirow{#4}[#5]{#6}[#7]{#8}}}%
 }
-\providecommand*{\multicolumnrow}{\LWR@origmulticolumnrow}
-}% \@xmultirow defined, so multirow was loaded
+
+}% \@ifundefined{@xmultirow}
+
+\providecommand*{\multicolumnrow}{\LWR@print@multicolumnrow}
+
 }% AtBeginDocument
 \end{warpall}
 \begin{warpHTML}
@@ -7602,13 +7817,13 @@ rowspan="#2" %
 
 
 \begin{warpHTML}
-\newcommand*{\LWR@origtoprule}[1][]{\hline}
-\newcommand*{\LWR@origmidrule}[1][]{\hline}
-\LetLtxMacro\LWR@origcmidrule\cline
-\newcommand*{\LWR@origbottomrule}[1][]{\hline}
-\newcommand*{\LWR@origaddlinespace}[1][]{}
-\newcommand*{\LWR@origmorecmidrules}{}
-\newcommand*{\LWR@origspecialrule}[3]{\hline}
+\newcommand*{\toprule}[1][]{\hline}
+\newcommand*{\midrule}[1][]{\hline}
+\LetLtxMacro\cmidrule\cline
+\newcommand*{\bottomrule}[1][]{\hline}
+\newcommand*{\addlinespace}[1][]{}
+\newcommand*{\morecmidrules}{}
+\newcommand*{\specialrule}[3]{\hline}
 \LetLtxMacro\LWR@orignoalign\noalign
 
 \newcommand{\LWR@tabularnoalign}[1]{%
@@ -7678,11 +7893,8 @@ rowspan="#2" %
 \boolfalse{LWR@tabularcelladded}%
 \LWR@clearmidrules%
 \LetLtxMacro{\\}{\LWR@tabularendofline}%
-\LetLtxMacro\columncolor\LWR@HTMLcolumncolor%
-\LetLtxMacro\rowcolor\LWR@HTMLrowcolor%
-\LetLtxMacro\cellcolor\LWR@HTMLcellcolor%
-\LetLtxMacro\arrayrulecolor\LWR@HTMLarrayrulecolor%
-\LetLtxMacro\doublerulesepcolor\LWR@HTMLdoublerulesepcolor%
+\LetLtxMacro\arrayrulecolor\arrayrulecolornexttoken%
+\LetLtxMacro\doublerulesepcolor\doublerulesepcolornexttoken%
 \renewcommand*{\LWR@columnHTMLcolor}{}%
 \renewcommand*{\LWR@rowHTMLcolor}{}%
 \renewcommand*{\LWR@cellHTMLcolor}{}%
@@ -7693,44 +7905,6 @@ rowspan="#2" %
 \LetLtxMacro\noalign\LWR@tabularnoalign%
 \LetLtxMacro\hline\LWR@HTMLhline%
 \LetLtxMacro\cline\LWR@HTMLcline%
-\DeclareDocumentCommand{\toprule}{o d()}%
-    {%
-        \IfValueTF{##1}%
-            {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
-            {%
-                \ifbool{FormatWP}%
-                {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
-                {\booltrue{LWR@doingtbrule}}%
-            }%
-    \LWR@getmynexttoken}%
-\DeclareDocumentCommand{\midrule}{o d()}%
-    {%
-        \IfValueTF{##1}%
-            {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
-            {%
-                \ifbool{FormatWP}%
-                {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
-                {\addtocounter{LWR@hlines}{1}}%
-            }%
-    \LWR@getmynexttoken}%
-\DeclareDocumentCommand{\cmidrule}{O{\LWR@cmidrulewidth} d() m}{%
-    \LWR@docmidrule[##1](##2){##3}%
-    \LWR@getmynexttoken%
-}%
-\DeclareDocumentCommand{\bottomrule}{o d()}{%
-    \IfValueTF{##1}%
-        {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
-        {%
-            \ifbool{FormatWP}%
-            {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}}%
-            {\booltrue{LWR@doingtbrule}}%
-        }%
-    \LWR@getmynexttoken%
-}%
-\DeclareDocumentCommand{\addlinespace}{o}{}%
-\DeclareDocumentCommand{\morecmidrules}{}{}%
-\DeclareDocumentCommand{\specialrule}{m m m d()}%
-    {\LWR@docmidrule[##1](){1-\arabic{LWR@tabletotalcols}}\LWR@getmynexttoken}%
 \DeclareDocumentCommand{\hdashline}{o}{%
     \ifbool{FormatWP}%
         {\LWR@docdashline{1-\arabic{LWR@tabletotalcols}}}%
@@ -7801,11 +7975,11 @@ rowspan="#2" %
 \global\boolfalse{LWR@intabularmetadata}%
 \addtocounter{LWR@tabulardepth}{-1}%
 \protected\gdef&{\LWR@origampmacro}%
-\EndDefiningTabulars%
+\StopDefiningTabulars%
 \LWR@traceinfo{LWR@tabular finished ending}%
 }
 
-\EndDefiningTabulars
+\StopDefiningTabulars
 
 \end{warpHTML}
 
@@ -7868,16 +8042,16 @@ rowspan="#2" %
     {% pars allowed
         \ifbool{LWR@doingapar}%
         {% par started
-            \LWR@htmltag{a \LWR@origmbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
+            \LWR@htmltag{a \LWR@print@mbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
         }% par started
         {% par not started
             \LWR@stoppars%
-            \LWR@htmltag{a \LWR@origmbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
+            \LWR@htmltag{a \LWR@print@mbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
             \LWR@startpars%
         }% par not started
     }% pars allowed
     {% pars not allowed
-        \LWR@htmltag{a \LWR@origmbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
+        \LWR@htmltag{a \LWR@print@mbox{id="\LWR@sanitized"}}\LWR@htmltag{/a}%
     }% pars not allowed
 }% not lateximage
 }
@@ -7901,7 +8075,7 @@ rowspan="#2" %
 \LWR@traceinfo{LWR@startref A: !#1!}%
 \LWR@htmltag{a href="%
 \LWR@traceinfo{LWR@startref B}%
-\LWR@origmbox{\LWR@htmlrefsectionfilename{#1}}%
+\LWR@print@mbox{\LWR@htmlrefsectionfilename{#1}}%
 \LWR@traceinfo{LWR@startref C}%
 \LWR@origpound%
 \LWR@traceinfo{LWR@startref D: !#1!}%
@@ -7919,7 +8093,7 @@ rowspan="#2" %
     }%
     {%
         \LWR@traceinfo{LWR@startref D3}%
-        \LWR@origmbox{\LWR@sanitized}%
+        \LWR@print@mbox{\LWR@sanitized}%
     }%
 }%
 \LWR@traceinfo{LWR@startref E}%
@@ -7940,6 +8114,9 @@ rowspan="#2" %
 {\LWR@origref{#2}}%
 {\LWR@subnewref{#2}{#2}}%
 }
+\NewDocumentCommand{\LWR@ref@ignorestar}{s m}{%
+    \LWR@origref{#2}%
+}
 
 \newcommand*{\pagerefPageFor}{see }
 \NewDocumentCommand{\LWR@newpageref}{s m}{%
@@ -7969,15 +8146,17 @@ autopage-\theLWR@currentautosec%
 }
 }
 
-
-\NewDocumentCommand{\LWR@subhyperref}{m +m}{%
+\NewDocumentCommand{\LWR@subhyperref}{m}{%
 \LWR@traceinfo{LWR@subhyperref !#1!}%
 \LWR@sanitize{#1}%
 \LWR@htmltag{%
     a href="\LWR@sanitized" %
     target="\_{}blank"\LWR@orignewline%
 }%
-#2%
+}
+
+\newcommand{\LWR@subhyperreftext}[1]{%
+#1%
 \LWR@htmltag{/a}%
 \LWR@ensuredoingapar%
 }
@@ -7994,10 +8173,11 @@ autopage-\theLWR@currentautosec%
 \LWR@ensuredoingapar%
 }
 
-\DeclareDocumentCommand{\LWR@hrefb}{O{} m +m}{%
+\DeclareDocumentCommand{\LWR@hrefb}{O{} m}{%
 \LWR@ensuredoingapar%
-\LWR@subhyperref{#2}{#3}%
-\endgroup%
+\LWR@subhyperref{#2}%
+\endgroup% restore catcodes
+\LWR@subhyperreftext%
 }
 
 \newrobustcmd*{\href}{%
@@ -8068,7 +8248,10 @@ autopage-\theLWR@currentautosec%
 \booltrue{LWR@freezethisautoid}%
 \begingroup%
 \LWR@origraggedright%
-\LWR@htmltag{figure id="\LWR@origmbox{autoid-\arabic{LWR@thisautoid}}" class="#1"}%
+\LWR@htmltag{%
+    figure id="\LWR@print@mbox{autoid-\arabic{LWR@thisautoid}}" % space
+    class="#1 \csuse{LWR@floatstyle@#1}"%
+}%
 \ifbool{FormatWP}{%
     \LWR@orignewline%
     \LWR@BlockClassWP{}{}{wp#1}%
@@ -8123,7 +8306,7 @@ autopage-\theLWR@currentautosec%
 {
     \ifbool{LWR@freezethisautoid}{}{%
         \addtocounter{LWR@thisautoid}{1}%
-        \LWR@htmltag{a id="\LWR@origmbox{autoid-\arabic{LWR@thisautoid}}"}%
+        \LWR@htmltag{a id="\LWR@print@mbox{autoid-\arabic{LWR@thisautoid}}"}%
             \LWR@htmltag{/a}%
     }%
 }
@@ -8180,7 +8363,7 @@ autopage-\theLWR@currentautosec%
 \LWR@htmlblocktag{figcaption}%
 \ifbool{FormatWP}{%
 \begin{BlockClass}[font-style:italic]{italic}
-\LWR@origvspace*{\baselineskip}
+\LWR@print@vspace*{\baselineskip}
 }{}%
 \LWR@traceinfo{LWR@figcaption env start: done}%
 }
@@ -8232,7 +8415,7 @@ autopage-\theLWR@currentautosec%
 
 \def\LWR@LTcaptionlistentry{%
 \LWR@ensuredoingapar%
-\LWR@htmltag{a id="\LWR@origmbox{autoid-\arabic{LWR@thisautoid}}"}\LWR@htmltag{/a}%
+\LWR@htmltag{a id="\LWR@print@mbox{autoid-\arabic{LWR@thisautoid}}"}\LWR@htmltag{/a}%
   \bgroup
   \@ifstar{\egroup\LWR@LT@captionlistentry}% gobble *
           {\egroup\LWR@LT@captionlistentry}}%
@@ -8354,6 +8537,9 @@ autopage-\theLWR@currentautosec%
 
 
 \NewDocumentCommand{\listof}{m +m}{%
+\@ifundefined{l@#1}{%
+    \csdef{l@#1}[2]{\hypertocfloat{1}{#1}{\csuse{ext@#1}}{##1}{##2}}%
+}{}%
 \LWR@subtableofcontents{\@nameuse{ext@#1}}{#2}
 \expandafter\newwrite\csname tf@\csname ext@#1\endcsname\endcsname
 \immediate\openout \csname tf@\csname ext@#1\endcsname\endcsname
@@ -8406,7 +8592,7 @@ autopage-\theLWR@currentautosec%
 \ifthenelse{\cnttest{#1}{<=}{\value{tocdepth}}}{%
     \LWR@startpars%
     \LWR@subhyperrefclass{%
-        \LWR@htmlrefsectionfilename{autopage-#4}\LWR@origpound\LWR@origmbox{autosec-#4}%
+        \LWR@htmlrefsectionfilename{autopage-#4}\LWR@origpound\LWR@print@mbox{autosec-#4}%
     }{#3}{toc#2}%
     \LWR@stoppars%
 }%
@@ -8435,7 +8621,7 @@ autopage-\theLWR@currentautosec%
     \LWR@startpars%
     \LWR@subhyperrefclass{%
     \LWR@htmlrefsectionfilename{autopage-\arabic{LWR@nextautopage}}%
-    \LWR@origpound\LWR@origmbox{autoid-\arabic{LWR@nextautoid}}}%
+    \LWR@origpound\LWR@print@mbox{autoid-\arabic{LWR@nextautoid}}}%
     {#4}{toc#2}%
     \LWR@stoppars%
 }{}%
@@ -8567,14 +8753,17 @@ autopage-\theLWR@currentautosec%
 
 \end{warpHTML}
 
+
 \begin{warpHTML}
+
 \newcommand*{\LWR@restoreorigformatting}{%
 \LWR@traceinfo{LWR@restoreorigformatting}%
+\renewcommand*{\LWR@formatting}{print}%
 \linespread{1}%
 \LetLtxMacro\caption@begin\LWR@origcaption@begin%
 \LetLtxMacro\caption@end\LWR@origcaption@end%
 \let\par\LWR@origpar%
-\LetLtxMacro\ref\LWR@origref%{} syntax highlighting
+\LetLtxMacro\ref\LWR@origref%   {} syntax highlighting
 \let\normalsize\LWR@orignormalsize%
 \let\small\LWR@origsmall%
 \let\footnotesize\LWR@origfootnotesize%
@@ -8585,16 +8774,11 @@ autopage-\theLWR@currentautosec%
 \let\LARGE\LWR@origLARGE%
 \let\huge\LWR@orighuge%
 \let\Huge\LWR@origHuge%
-\RenewDocumentCommand{\InlineClass}{o m +m}{##3}%
-\RenewDocumentEnvironment{BlockClass}{o m}{}{}%
-\renewcommand{\BlockClassSingle}[2]{##2}%
-\LetLtxMacro\hspace\LWR@orighspace%
+\LWR@select@print@hspace%
 \LetLtxMacro\hfill\LWR@orighfill%
 \LetLtxMacro\hfil\LWR@orighfil%
-\LetLtxMacro\rule\LWR@origrule%
 \LetLtxMacro\hrulefill\LWR@orighrulefill%
 \LetLtxMacro\dotfill\LWR@origdotfill%
-\let\vspace\LWR@origvspace%
 \let\hss\LWR@orighss%
 \let\llap\LWR@origllap%
 \let\rlap\LWR@origrlap%
@@ -8607,28 +8791,28 @@ autopage-\theLWR@currentautosec%
 \let\textellipsis\LWR@origtextellipsis%
 \let\textless\LWR@origtextless%
 \let\textgreater\LWR@origtextgreater%
-\LetLtxMacro{\textrm}{\LWR@origtextrm}%
-\LetLtxMacro{\textsf}{\LWR@origtextsf}%
-\LetLtxMacro{\texttt}{\LWR@origtexttt}%
-\LetLtxMacro{\textbf}{\LWR@origtextbf}%
-\LetLtxMacro{\textmd}{\LWR@origtextmd}%
-\LetLtxMacro{\textit}{\LWR@origtextit}%
-\LetLtxMacro{\textsl}{\LWR@origtextsl}%
-\LetLtxMacro{\textsc}{\LWR@origtextsc}%
-\LetLtxMacro{\textup}{\LWR@origtextup}%
-\LetLtxMacro{\textnormal}{\LWR@origtextnormal}%
-\LetLtxMacro{\emph}{\LWR@origemph}%
-\LetLtxMacro{\rmfamily}{\LWR@origrmfamily}%
-\LetLtxMacro{\sffamily}{\LWR@origsffamily}%
-\LetLtxMacro{\ttfamily}{\LWR@origttfamily}%
-\LetLtxMacro{\bfseries}{\LWR@origbfseries}%
-\LetLtxMacro{\mdseries}{\LWR@origmdseries}%
-\LetLtxMacro{\upshape}{\LWR@origupshape}%
-\LetLtxMacro{\slshape}{\LWR@origslshape}%
-\LetLtxMacro{\scshape}{\LWR@origscshape}%
-\LetLtxMacro{\itshape}{\LWR@origitshape}%
-\LetLtxMacro{\em}{\LWR@origem}%
-\LetLtxMacro{\normalfont}{\LWR@orignormalfont}%
+\LetLtxMacro\textrm\LWR@origtextrm%
+\LetLtxMacro\textsf\LWR@origtextsf%
+\LetLtxMacro\texttt\LWR@origtexttt%
+\LetLtxMacro\textbf\LWR@origtextbf%
+\LetLtxMacro\textmd\LWR@origtextmd%
+\LetLtxMacro\textit\LWR@origtextit%
+\LetLtxMacro\textsl\LWR@origtextsl%
+\LetLtxMacro\textsc\LWR@origtextsc%
+\LetLtxMacro\textup\LWR@origtextup%
+\LetLtxMacro\textnormal\LWR@origtextnormal%
+\LetLtxMacro\emph\LWR@origemph%
+\LetLtxMacro\rmfamily\LWR@origrmfamily%
+\LetLtxMacro\sffamily\LWR@origsffamily%
+\LetLtxMacro\ttfamily\LWR@origttfamily%
+\LetLtxMacro\bfseries\LWR@origbfseries%
+\LetLtxMacro\mdseries\LWR@origmdseries%
+\LetLtxMacro\upshape\LWR@origupshape%
+\LetLtxMacro\slshape\LWR@origslshape%
+\LetLtxMacro\scshape\LWR@origscshape%
+\LetLtxMacro\itshape\LWR@origitshape%
+\LetLtxMacro\em\LWR@origem%
+\LetLtxMacro\normalfont\LWR@orignormalfont%
 \let\sp\LWR@origsp%
 \let\sb\LWR@origsb%
 \LetLtxMacro\textsuperscript\LWR@origtextsuperscript%
@@ -8644,30 +8828,8 @@ autopage-\theLWR@currentautosec%
 \LetLtxMacro\endtabular\LWR@origendtabular%
 \LetLtxMacro\noalign\LWR@orignoalign%
 \LetLtxMacro\hline\LWR@orighline%
-\LetLtxMacro\toprule\LWR@origtoprule%
-\LetLtxMacro\midrule\LWR@origmidrule%
-\LetLtxMacro\cmidrule\LWR@origcmidrule%
-\LetLtxMacro\bottomrule\LWR@origbottomrule%
-\LetLtxMacro\addlinespace\LWR@origaddlinespace%
-\LetLtxMacro\morecmidrules\LWR@origmorecmidrules%
-\LetLtxMacro\specialrule\LWR@origspecialrule%
 \let\newline\LWR@orignewline%
-\LetLtxMacro{\raisebox}{\LWR@origraisebox}%
 \LetLtxMacro\includegraphics\LWR@origincludegraphics%
-\LetLtxMacro{\scalebox}{\LWR@origscalebox}%
-\LetLtxMacro{\rotatebox}{\LWR@origrotatebox}%
-\let\reflectbox\LWR@origreflectbox%
-\LetLtxMacro\resizebox\LWR@origresizebox%
-\let\framebox\LWR@origframebox%
-\LetLtxMacro\mbox\LWR@origmbox%
-\LetLtxMacro\makebox\LWR@origmakebox%
-\let\fbox\LWRprint@fbox%
-\let\fboxBlock\LWRprint@fbox%
-\LetLtxMacro\fminipage\LWRprint@fminipage%
-\LetLtxMacro\endfminipage\endLWRprint@fminipage%
-\LetLtxMacro\minipage\LWR@origminipage%
-\let\endminipage\LWR@origendminipage%
-\LetLtxMacro\parbox\LWR@origparbox%
 \let\TeX\LWR@origTeX%
 \let\LaTeX\LWR@origLaTeX%
 \let\LaTeXe\LWR@origLaTeXe%
@@ -8678,8 +8840,16 @@ autopage-\theLWR@currentautosec%
 \LWR@FBcancel%
 }
 \end{warpHTML}
-\begin{warpHTML}
 
+\begin{warpall}
+
+\newcommand*{\mathimagename}{math image}
+
+\newcommand*{\packagediagramname}{diagram}
+
+\end{warpall}
+
+\begin{warpHTML}
 \newcounter{LWR@externalfilecnt}
 
 \newbool{LWR@indisplaymathimage}
@@ -8745,13 +8915,15 @@ autopage-\theLWR@currentautosec%
         bool{mathjax} or
         ( bool{FormatWP} and bool{WPMarkMath} )
     ) and
-    ( not test { \ifstrequal {#2} {(math image)} } )% from \ensuredmath
+    ( not test { \ifstrequal {#2} {(\mathimagename)} } ) and % from \ensuredmath
+    ( not bool{LWR@dynamicmath} )
 }%
 {%
+    \LWR@traceinfo{LWR@subsingledollar: Mathjax}%
     {\textbackslash(\LWR@HTMLsanitize{#4}\textbackslash)}%
 }% mathjax
 {% not mathjax
-\LWR@traceinfo{LWR@subsingledollar: not mathjax}%
+\LWR@traceinfo{LWR@subsingledollar: NOT mathjax, or is ensuremath, or is dynamic}%
     \begingroup%
     \LWR@restoreorigformatting%
     \RenewDocumentEnvironment{lateximage}{s o o o}{}{}% inside group
@@ -8763,7 +8935,19 @@ autopage-\theLWR@currentautosec%
     \LWR@traceinfo{Using font shape \LWR@f@shape}%
     \csuse{LWR@orig\LWR@f@shape shape}%
     \global\advance\c@LWR@lateximagedepth 1\relax%
-    \global\sbox{\LWR@singledollarbox}{#4}%
+    \ifmmode%
+        \global\sbox{\LWR@singledollarbox}{#4}%
+    \else%
+        \ifbool{LWR@dynamicmath}{%
+            \ifbool{mathjax}{%
+                \global\sbox{\LWR@singledollarbox}{\LWR@origensuredmath{#4}}%
+            }{%
+                \global\sbox{\LWR@singledollarbox}{#4}%
+            }%
+        }{%
+            \global\sbox{\LWR@singledollarbox}{#4}%
+        }%
+    \fi%
     \global\sbox{\LWR@singledollarbox}{%
         \usebox{\LWR@singledollarbox}%
         \hspace*{-10sp}%
@@ -8814,30 +8998,39 @@ autopage-\theLWR@currentautosec%
     \ifdimgreater{\LWR@singledollardepth}{0.05ex}{%
         \def\LWR@singledollardepthstyle{%
             \ ; % extra space
-            \LWR@origmbox{%
+            \LWR@print@mbox{%
                 vertical-align:-\LWR@convertto{em}{\the\LWR@singledollardepth} em%
             } % extra space
         }%
     }{%
         \def\LWR@singledollardepthstyle{}%
     }%
-    \IfValueTF{#1}{%
-        \LWR@findcurrenttextcolor% sets \LWR@tempcolor
-        \begin{lateximage}*% use hashing
-            [#2]% alt
-            [% addl' hashing
-                #3%
-                FM\LWR@f@family%
-                SR\LWR@f@series%
-                SH\LWR@f@shape%
-                CL\LWR@tempcolor%
-            ]%
-            [\LWR@singledollarstyle \LWR@singledollardepthstyle]% CSS
-    }{%
+    \ifbool{LWR@dynamicmath}{%
+        \LWR@traceinfo{subsingledollar: dynamic}%
         \begin{lateximage}% no hashing
-            [#2]% alt
+            [(\mathimagename)]% alt tag
             []% no add'l hashing
             [\LWR@singledollarstyle \LWR@singledollardepthstyle]% CSS
+    }{%
+        \LWR@traceinfo{subsingledollar: static}%
+        \IfValueTF{#1}{%
+            \LWR@findcurrenttextcolor% sets \LWR@tempcolor
+            \begin{lateximage}*% use hashing
+                [#2]% alt
+                [% addl' hashing
+                    #3%
+                    FM\LWR@f@family%
+                    SR\LWR@f@series%
+                    SH\LWR@f@shape%
+                    CL\LWR@tempcolor%
+                ]%
+                [\LWR@singledollarstyle \LWR@singledollardepthstyle]% CSS
+        }{%
+            \begin{lateximage}% no hashing
+                [#2]% alt
+                []% no add'l hashing
+                [\LWR@singledollarstyle \LWR@singledollardepthstyle]% CSS
+        }%
     }%
     \LWR@addbaselinemarker%
     \hspace*{-10sp}%
@@ -8923,7 +9116,7 @@ autopage-\theLWR@currentautosec%
 
 \renewcommand{\@ensuredmath}[1]{%
 \ifbool{mathjax}{%
-    \LWR@subsingledollar*{(math image)}{%
+    \LWR@subsingledollar*{(\mathimagename)}{%
            \protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
     }{\relax%
         \LWR@origensuredmath{#1}%
@@ -8935,7 +9128,7 @@ autopage-\theLWR@currentautosec%
     \ifnumcomp{\value{LWR@lateximagedepth}}{>}{0}%
     {\LWR@origensuredmath{#1}}%
     {%
-        \LWR@subsingledollar*{(math image)}{%
+        \LWR@subsingledollar*{(\mathimagename)}{%
            \protect\LWR@HTMLsanitize{\detokenize\expandafter{#1}}%
         }{%
             \LWR@origensuredmath{#1}%
@@ -9684,7 +9877,7 @@ autopage-\theLWR@currentautosec%
     \LWR@traceinfo{lateximage: about to create a new page}%
     \LWR@orignewpage%
     \LWR@traceinfo{lateximage: about to create minipage}%
-    \LWR@origminipage{6in}%
+    \LWR@print@minipage{6in}%
     \csuse{LWR@orig\LateximageFontSizeName}%
     \LWR@traceinfo{lateximage: about to temporarily restore formatting}%
     \LWR@restoreorigformatting%
@@ -9721,10 +9914,10 @@ autopage-\theLWR@currentautosec%
 }%
 {% end of outer-most lateximage
 \LWR@traceinfo{lateximage: ending outer-most lateximage}%
-    \LWR@origendminipage%
+    \endLWR@print@minipage%
     \LWR@orignewpage%
     \LWR@origscriptsize%
-    \LWR@origvspace*{.5\baselineskip}%
+    \LWR@print@vspace*{.5\baselineskip}%
     \LWR@htmlclosecomment%
     \LWR@traceinfo{lateximage: The page after the image is \arabic{page}}%
     \IfBooleanTF{#1}% starred
@@ -9732,14 +9925,14 @@ autopage-\theLWR@currentautosec%
         \LWR@subinlineimage[#2]{lateximage}%
         {%
             lateximages\OSPathSymbol%
-            \LWR@origmbox{\LWR@hashedname}%
+            \LWR@print@mbox{\LWR@hashedname}%
         }{svg}{#4}%
     }% hash
     {% no hash
         \LWR@subinlineimage[#2]{lateximage}%
         {%
             lateximages\OSPathSymbol%
-            \LWR@origmbox{lateximage-\theLWR@externalfilecnt}%
+            \LWR@print@mbox{lateximage-\theLWR@externalfilecnt}%
         }{svg}{#4}%
     }% no hash
     \LWR@ensuredoingapar%
@@ -9770,7 +9963,7 @@ autopage-\theLWR@currentautosec%
 {
 \LWR@forcenewpage
 \ifbool{FormatWP}
-{\BlockClass[\LWR@origmbox{text-align:center}]{center}}
+{\BlockClass[\LWR@print@mbox{text-align:center}]{center}}
 {\BlockClass{center}}
 }
 {\endBlockClass}
@@ -9779,7 +9972,7 @@ autopage-\theLWR@currentautosec%
 {
 \LWR@forcenewpage
 \ifbool{FormatWP}
-{\BlockClass[\LWR@origmbox{text-align:right}]{flushright}}
+{\BlockClass[\LWR@print@mbox{text-align:right}]{flushright}}
 {\BlockClass{flushright}}
 }
 {\endBlockClass}
@@ -9788,7 +9981,7 @@ autopage-\theLWR@currentautosec%
 {
 \LWR@forcenewpage
 \ifbool{FormatWP}
-{\BlockClass[\LWR@origmbox{text-align:left}]{flushleft}}
+{\BlockClass[\LWR@print@mbox{text-align:left}]{flushleft}}
 {\BlockClass{flushleft}}
 }
 {\endBlockClass}
@@ -9880,16 +10073,12 @@ autopage-\theLWR@currentautosec%
 \@ifpackageloaded{xcolor}{
 \LWR@traceinfo{patching xcolor}
 \LetLtxMacro\colorboxBlock\colorbox
-\warpprintonly{
-\LetLtxMacro\LWRprint@colorboxBlock\colorbox
-\LetLtxMacro\LWRorigprint@fcolorbox\fcolorbox
-\LetLtxMacro\LWRorigprint@fcolorboxBlock\fcolorbox
-}
+\LetLtxMacro\LWR@orig@print@fcolorbox\fcolorbox
 
 \newsavebox{\LWR@colorminipagebox}
 
-\DeclareDocumentCommand{\LWRprint@fcolorbox}{o m o m +m}{%
-\LWR@traceinfo{LWRprint@fcolorbox #2 #4}%
+\NewDocumentCommand{\LWR@print@fcolorbox}{o m o m +m}{%
+\LWR@traceinfo{LWR@print@fcolorbox #2 #4}%
 \begin{lrbox}{\LWR@colorminipagebox}%
 #5%
 \end{lrbox}%
@@ -9910,20 +10099,23 @@ autopage-\theLWR@currentautosec%
 \IfValueTF{#1}%
 {%
     \IfValueTF{#3}%
-    {\LWRorigprint@fcolorbox[#1]{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
-    {\LWRorigprint@fcolorbox[#1]{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
+    {\LWR@orig@print@fcolorbox[#1]{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
+    {\LWR@orig@print@fcolorbox[#1]{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
 }%
 {% no value #1
     \IfValueTF{#3}%
-    {\LWRorigprint@fcolorbox{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
-    {\LWRorigprint@fcolorbox{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
+    {\LWR@orig@print@fcolorbox{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
+    {\LWR@orig@print@fcolorbox{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
 }% no value #1
 }% #4 not none
-\LWR@traceinfo{LWRprint@fcolorbox done}%
+\LWR@traceinfo{LWR@print@fcolorbox done}%
 }
-\LetLtxMacro\LWRprint@fcolorboxBlock\LWRprint@fcolorbox
 
-\NewDocumentEnvironment{LWRprint@fcolorminipage}{o m o m O{c} O{} o m}
+\renewcommand*{\fcolorbox}{\LWR@print@fcolorbox}
+\newcommand*{\LWR@print@fcolorboxBlock}{\LWR@print@fcolorbox}
+\newcommand*{\fcolorboxBlock}{\LWR@print@fcolorboxBlock}
+
+\NewDocumentEnvironment{LWR@print@fcolorminipage}{o m o m O{c} O{} o m}
 {%
 \LWR@traceinfo{*** fcolorminipage: #2 #4 #8}%
 \begin{lrbox}{\LWR@colorminipagebox}%
@@ -9950,31 +10142,21 @@ autopage-\theLWR@currentautosec%
     \IfValueTF{#1}%
     {%
     \IfValueTF{#3}%
-    {\LWRorigprint@fcolorbox[#1]{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
-    {\LWRorigprint@fcolorbox[#1]{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
+    {\LWR@orig@print@fcolorbox[#1]{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
+    {\LWR@orig@print@fcolorbox[#1]{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
     }%
     {% no value #1
     \IfValueTF{#3}%
-    {\LWRorigprint@fcolorbox{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
-    {\LWRorigprint@fcolorbox{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
+    {\LWR@orig@print@fcolorbox{#2}[#3]{#4}{\usebox{\LWR@colorminipagebox}}}%
+    {\LWR@orig@print@fcolorbox{#2}{#4}{\usebox{\LWR@colorminipagebox}}}%
     }% no value #1
 }% #4 not none
 \LWR@traceinfo{*** finished end fcolorminipage}%
 }
 
-\newcommand*{\LWR@restoreorigprintxcolor}{%
-\LWR@traceinfo{LWR@restoreorigprintxcolor}%
-\LetLtxMacro\colorboxBlock\LWRprint@colorboxBlock%
-\LetLtxMacro\fcolorbox\LWRprint@fcolorbox%
-\LetLtxMacro\fcolorboxBlock\LWRprint@fcolorboxBlock%
-\LetLtxMacro\fcolorminipage\LWRprint@fcolorminipage%
-\LetLtxMacro\endfcolorminipage\endLWRprint@fcolorminipage%
-}
-
-\appto\LWR@restoreorigformatting{%
-\LWR@restoreorigprintxcolor%
-}
-\warpprintonly{\LWR@restoreorigprintxcolor}
+\newenvironment*{fcolorminipage}
+    {\LWR@print@fcolorminipage}
+    {\endLWR@print@fcolorminipage}
 
 \LWR@traceinfo{xcolor patches done}
 }{}% xcolor loaded
@@ -10014,7 +10196,7 @@ autopage-\theLWR@currentautosec%
         \renewcommand*{\@@@setcref}[2]{#1{\ref{#2}}{}{}}
     }{
         \PackageWarning{lwarp-cleveref}{
-            Unknown verison of cleveref.
+            Unknown version of cleveref.
             \protect\cref\space will fail.
         }%
     }
@@ -10036,7 +10218,7 @@ autopage-\theLWR@currentautosec%
         }
     }{
         \PackageWarning{lwarp-cleveref}{
-            Unknown verison of cleveref.
+            Unknown version of cleveref.
             \protect\crefrange\space will fail.
         }
     }
@@ -10064,7 +10246,7 @@ autopage-\theLWR@currentautosec%
     }
     {
         \PackageWarning{lwarp-cleveref}{
-            Unknown verison of cleveref.
+            Unknown version of cleveref.
             \protect\cpageref\space will fail.
         }
     }
@@ -10093,7 +10275,7 @@ autopage-\theLWR@currentautosec%
     }
     {
         \PackageWarning{lwarp-cleveref}{
-            Unknown verison of cleveref.
+            Unknown version of cleveref.
             \protect\cpagerefrange\space will fail.
         }
     }
@@ -10140,7 +10322,7 @@ autopage-\theLWR@currentautosec%
 \begin{warpHTML}
 \newbool{LWR@minipagethispar}
 \boolfalse{LWR@minipagethispar}
-\RenewDocumentEnvironment{minipage}{O{t} o O{t} m}
+\NewDocumentEnvironment{LWR@HTML@minipage}{O{t} o O{t} m}
 {%
 \LWR@traceinfo{minipage}%
 \begingroup
@@ -10161,18 +10343,21 @@ autopage-\theLWR@currentautosec%
 \ifbool{FormatWP}{%
 
 \addtocounter{LWR@thisautoidWP}{1}%
-\LWR@htmltag{div id="\LWR@origmbox{autoidWP-\arabic{LWR@thisautoidWP}}" class="wpminipage"}%
+\LWR@htmltag{%
+    div id="\LWR@print@mbox{autoidWP-\arabic{LWR@thisautoidWP}}" %
+    class="wpminipage"%
+}%
 
 }{}%
 \LWR@traceinfo{minipage: creating div class}%
 \LWR@htmltag{div class="minipage" style="%
-\ifthenelse{\equal{#1}{t}}{\LWR@origmbox{vertical-align:bottom} ; }{}%
-\ifthenelse{\equal{#1}{c}}{\LWR@origmbox{vertical-align:middle} ; }{}%
-\ifthenelse{\equal{#1}{b}}{\LWR@origmbox{vertical-align:top} ; }{}%
-\ifthenelse{\equal{#3}{t}}{\LWR@origmbox{justify-content:flex-start} ; }{}%
-\ifthenelse{\equal{#3}{c}}{\LWR@origmbox{justify-content:center} ; }{}%
-\ifthenelse{\equal{#3}{b}}{\LWR@origmbox{justify-content:flex-end} ; }{}%
-\ifthenelse{\equal{#3}{s}}{\LWR@origmbox{justify-content:space-between} ; }{}%
+\ifthenelse{\equal{#1}{t}}{\LWR@print@mbox{vertical-align:bottom} ; }{}%
+\ifthenelse{\equal{#1}{c}}{\LWR@print@mbox{vertical-align:middle} ; }{}%
+\ifthenelse{\equal{#1}{b}}{\LWR@print@mbox{vertical-align:top} ; }{}%
+\ifthenelse{\equal{#3}{t}}{\LWR@print@mbox{justify-content:flex-start} ; }{}%
+\ifthenelse{\equal{#3}{c}}{\LWR@print@mbox{justify-content:center} ; }{}%
+\ifthenelse{\equal{#3}{b}}{\LWR@print@mbox{justify-content:flex-end} ; }{}%
+\ifthenelse{\equal{#3}{s}}{\LWR@print@mbox{justify-content:space-between} ; }{}%
 \LWR@traceinfo{minipage: about to print the width of \LWR@printlength{\LWR@minipagewidth}}%
 \ifbool{LWR@minipagefullwidth}%
 {\boolfalse{LWR@minipagefullwidth}}%
@@ -10223,15 +10408,21 @@ autopage-\theLWR@currentautosec%
 \global\booltrue{LWR@minipagethispar}%
 \LWR@traceinfo{LWR@minipage: done}%
 }
-\RenewDocumentCommand{\parbox}{O{t} o O{t} m +m}
+
+\LWR@formattedenv{minipage}
+\NewDocumentCommand{\LWR@HTML@parbox}{O{t} o O{t} m +m}
 {
 \LWR@traceinfo{parbox of width #4}%
 \begin{minipage}[#1][#2][#3]{#4}%
 #5
 \end{minipage}%
 }
-\renewcommand*{\mbox}[1]{#1}
-\RenewDocumentCommand{\makebox}{d() o o m}{%
+
+\LWR@formatted{parbox}
+\newcommand*{\LWR@HTML@mbox}[1]{#1}
+
+\LWR@formatted{mbox}
+\NewDocumentCommand{\LWR@HTML@makebox}{d() o o m}{%
 \IfValueTF{#2}%
 {%
     {% scope
@@ -10241,8 +10432,8 @@ autopage-\theLWR@currentautosec%
     \ifstrequal{#3}{s}{\def\LWR@align{justify}}{}%
     \setlength{\LWR@tempwidth}{#2}%
     \InlineClass[%
-        \LWR@origmbox{display:inline-block} ; %
-        \LWR@origmbox{text-align}:\LWR@align\ ; %
+        \LWR@print@mbox{display:inline-block} ; %
+        \LWR@print@mbox{text-align}:\LWR@align\ ; %
         width:\LWR@printlength{\LWR@tempwidth}%
     ]%
     {makebox}%
@@ -10251,11 +10442,15 @@ autopage-\theLWR@currentautosec%
 }%
 {#4}% no width
 }
+
+\LWR@formatted{makebox}
 \LetLtxMacro\LWR@origframebox\framebox
 
-\RenewDocumentCommand{\framebox}{o o m}{%
+\NewDocumentCommand{\LWR@HTML@framebox}{o o m}{%
 \fbox{\makebox[#1][#2]{#3}}%
 }
+
+\LWR@formatted{framebox}
 \newlength{\LWR@atleastonept}
 
 \newcommand*{\LWR@forceminwidth}[1]{%
@@ -10272,17 +10467,20 @@ autopage-\theLWR@currentautosec%
 border:\LWR@printlength{\LWR@atleastonept} solid black ; %
 padding:\LWR@printlength{\fboxsep}%
 }
-\let\LWRprint@fbox\fbox
-\newcommand{\LWRhtml@fbox}[1]{%
+\newcommand{\LWR@HTML@fbox}[1]{%
 \LWR@traceinfo{HTML fbox}%
 \LWR@forceminwidth{\fboxrule}%
 \InlineClass[%
 \LWR@blackborderpadding%
 ]{fbox}{#1}
 }
-\AtBeginDocument{\let\fbox\LWRhtml@fbox}
-
-\newcommand{\fboxBlock}[1]{%
+\AtBeginDocument{\LWR@formatted{fbox}}
+\end{warpHTML}
+\begin{warpall}
+\let\fboxBlock\fbox
+\end{warpall}
+\begin{warpHTML}
+\newcommand{\LWR@HTML@fboxBlock}[1]{%
 \LWR@forceminwidth{\fboxrule}%
 \begin{BlockClass}[%
 \LWR@blackborderpadding%
@@ -10291,34 +10489,14 @@ padding:\LWR@printlength{\fboxsep}%
 \end{BlockClass}
 }
 
-\NewDocumentEnvironment{fminipage}{O{t} o O{t} m}
-{%
-\LWR@traceinfo{fminipage #1 #2 #3 #4}%
-\LWR@forceminwidth{\fboxrule}%
-\setlength{\LWR@tempwidth}{#4}%
-\IfValueT{#2}{\setlength{\LWR@tempheight}{#2}}%
-\begin{BlockClass}[%
-\LWR@blackborderpadding ; %
-\IfValueT{#2}{height:\LWR@printlength{\LWR@tempheight} ; }%
-width:\LWR@printlength{\LWR@tempwidth}%
-]{fminipage}%
-}
-{%
-\end{BlockClass}%
-\LWR@traceinfo{fminipage done}%
-}
-\LetLtxMacro{\LWR@origraisebox}{\raisebox}
-
-\RenewDocumentCommand{\raisebox}{m o o m}{%
-#4%
-}
+\LWR@formatted{fboxBlock}
 
 \end{warpHTML}
-
 \begin{warpall}
+
 \newsavebox{\LWR@fminipagebox}
 
-\NewDocumentEnvironment{LWRprint@fminipage}{O{t} o O{t} m}
+\NewDocumentEnvironment{LWR@print@fminipage}{O{t} o O{t} m}
 {%
 \IfValueTF{#3}%
 {\def\LWR@thisalign{#3}}
@@ -10338,15 +10516,40 @@ width:\LWR@printlength{\LWR@tempwidth}%
 \endminipage%
 }
 
+\newenvironment{fminipage}{\LWR@print@fminipage}{\endLWR@print@fminipage}
+
 \end{warpall}
 
-\begin{warpprint}
-\let\fboxBlock\fbox
+\begin{warpHTML}
+
+\NewDocumentEnvironment{LWR@HTML@fminipage}{O{t} o O{t} m}
+{%
+\LWR@traceinfo{fminipage #1 #2 #3 #4}%
+\LWR@forceminwidth{\fboxrule}%
+\setlength{\LWR@tempwidth}{#4}%
+\IfValueT{#2}{\setlength{\LWR@tempheight}{#2}}%
+\begin{BlockClass}[%
+\LWR@blackborderpadding ; %
+\IfValueT{#2}{height:\LWR@printlength{\LWR@tempheight} ; }%
+width:\LWR@printlength{\LWR@tempwidth}%
+]{fminipage}%
+}
+{%
+\end{BlockClass}%
+\LWR@traceinfo{fminipage done}%
+}
+
+\LWR@formattedenv{fminipage}
+\end{warpHTML}
+\begin{warpHTML}
 
-\LetLtxMacro{\fminipage}{\LWRprint@fminipage}
-\LetLtxMacro{\endfminipage}{\endLWRprint@fminipage}
+\NewDocumentCommand{\LWR@HTML@raisebox}{m o o m}{%
+#4%
+}
 
-\end{warpprint}
+\LWR@formatted{raisebox}
+
+\end{warpHTML}
 
 
 \begin{warpHTML}
@@ -10360,18 +10563,18 @@ width:\LWR@printlength{\LWR@tempwidth}%
 
 \DeclareRobustCommand{\LWR@HTMLemph}[1]{\LWR@htmlspan{em}{#1}}
 \DeclareRobustCommand{\LWR@nullemph}[1]{#1}
-\LetLtxMacro{\emph}{\LWR@HTMLemph}
+\LetLtxMacro\emph\LWR@HTMLemph
 
 \DeclareRobustCommand{\LWR@HTMLtextmd}[1]{%
 \LWR@HTMLtextstyle{font-weight:normal}{textmd}{#1}%
 }
 \DeclareRobustCommand{\LWR@nulltextmd}[1]{#1}
 
-\LetLtxMacro{\textmd}{\LWR@HTMLtextmd}
+\LetLtxMacro\textmd\LWR@HTMLtextmd
 
 \DeclareRobustCommand{\LWR@HTMLtextbf}[1]{\LWR@htmlspan{b}{#1}}
 \DeclareRobustCommand{\LWR@nulltextbf}[1]{#1}
-\LetLtxMacro{\textbf}{\LWR@HTMLtextbf}
+\LetLtxMacro\textbf\LWR@HTMLtextbf
 
 \DeclareRobustCommand{\LWR@HTMLtextrm}[1]{%
 \LWR@HTMLtextstyle{font-family:serif}{textrm}{#1}%
@@ -10379,17 +10582,17 @@ width:\LWR@printlength{\LWR@tempwidth}%
 
 \DeclareRobustCommand{\LWR@nulltextrm}[1]{#1}
 
-\LetLtxMacro{\textrm}{\LWR@HTMLtextrm}
+\LetLtxMacro\textrm\LWR@HTMLtextrm
 
 \DeclareRobustCommand{\LWR@HTMLtextsf}[1]{%
 \LWR@HTMLtextstyle{font-family:sans}{textsf}{#1}%
 }
 \DeclareRobustCommand{\LWR@nulltextsf}[1]{#1}
-\LetLtxMacro{\textsf}{\LWR@HTMLtextsf}
+\LetLtxMacro\textsf\LWR@HTMLtextsf
 
 \DeclareRobustCommand{\LWR@HTMLtexttt}[1]{\LWR@htmlspan{kbd}{#1}}
 \DeclareRobustCommand{\LWR@nulltexttt}[1]{#1}
-\LetLtxMacro{\texttt}{\LWR@HTMLtexttt}
+\LetLtxMacro\texttt\LWR@HTMLtexttt
 
 \DeclareRobustCommand{\LWR@HTMLtextup}[1]{%
 \LWR@HTMLtextstyle{font-variant:normal}{textup}{#1}%
@@ -10397,11 +10600,11 @@ width:\LWR@printlength{\LWR@tempwidth}%
 
 \DeclareRobustCommand{\LWR@nulltextup}[1]{#1}
 
-\LetLtxMacro{\textup}{\LWR@HTMLtextup}
+\LetLtxMacro\textup\LWR@HTMLtextup
 
 \DeclareRobustCommand{\LWR@HTMLtextit}[1]{\LWR@htmlspan{i}{#1}}
 \DeclareRobustCommand{\LWR@nulltextit}[1]{#1}
-\LetLtxMacro{\textit}{\LWR@HTMLtextit}
+\LetLtxMacro\textit\LWR@HTMLtextit
 
 \DeclareRobustCommand{\LWR@HTMLtextsc}[1]{%
 \LWR@HTMLtextstyle{font-variant:small-caps}{textsc}{#1}%
@@ -10409,7 +10612,7 @@ width:\LWR@printlength{\LWR@tempwidth}%
 
 \DeclareRobustCommand{\LWR@nulltextsc}[1]{#1}
 
-\LetLtxMacro{\textsc}{\LWR@HTMLtextsc}
+\LetLtxMacro\textsc\LWR@HTMLtextsc
 
 \DeclareRobustCommand{\LWR@HTMLtextsl}[1]{%
 \LWR@HTMLtextstyle{font-style:oblique}{textsl}{#1}%
@@ -10417,11 +10620,11 @@ width:\LWR@printlength{\LWR@tempwidth}%
 
 \DeclareRobustCommand{\LWR@nulltextsl}[1]{#1}
 
-\LetLtxMacro{\textsl}{\LWR@HTMLtextsl}
+\LetLtxMacro\textsl\LWR@HTMLtextsl
 
 \DeclareRobustCommand{\LWR@HTMLtextnormal}[1]{\textmd{\textrm{\textup{#1}}}}
 \DeclareRobustCommand{\LWR@nulltextnormal}[1]{#1}
-\LetLtxMacro{\textnormal}{\LWR@HTMLtextnormal}
+\LetLtxMacro\textnormal\LWR@HTMLtextnormal
 
 \DeclareRobustCommand{\LWR@nullrmfamily}{}
 \DeclareRobustCommand{\LWR@nullsffamily}{}
@@ -10436,28 +10639,28 @@ width:\LWR@printlength{\LWR@tempwidth}%
 \DeclareRobustCommand{\LWR@nullnormalfont}{}
 
 \newcommand*{\LWR@nullfonts}{%
-\LetLtxMacro{\emph}{\LWR@nullemph}%
-\LetLtxMacro{\textmd}{\LWR@nulltextmd}%
-\LetLtxMacro{\textbf}{\LWR@nulltextbf}%
-\LetLtxMacro{\textrm}{\LWR@nulltextrm}%
-\LetLtxMacro{\textsf}{\LWR@nulltextsf}%
-\LetLtxMacro{\texttt}{\LWR@nulltexttt}%
-\LetLtxMacro{\textup}{\LWR@nulltextup}%
-\LetLtxMacro{\textit}{\LWR@nulltextit}%
-\LetLtxMacro{\textsc}{\LWR@nulltextsc}%
-\LetLtxMacro{\textsl}{\LWR@nulltextsl}%
-\LetLtxMacro{\textnormal}{\LWR@nulltextnormal}%
-\LetLtxMacro{\rmfamily}{\LWR@nullrmfamily}%
-\LetLtxMacro{\sffamily}{\LWR@nullsffamily}%
-\LetLtxMacro{\ttfamily}{\LWR@nullttfamily}%
-\LetLtxMacro{\bfseries}{\LWR@nullbfseries}%
-\LetLtxMacro{\mdseries}{\LWR@nullmdseries}%
-\LetLtxMacro{\upshape}{\LWR@nullupshape}%
-\LetLtxMacro{\slshape}{\LWR@nullslshape}%
-\LetLtxMacro{\scshape}{\LWR@nullscshape}%
-\LetLtxMacro{\itshape}{\LWR@nullitshape}%
-\LetLtxMacro{\em}{\LWR@nullem}%
-\LetLtxMacro{\normalfont}{\LWR@nullnormalfont}%
+\LetLtxMacro\emph\LWR@nullemph%
+\LetLtxMacro\textmd\LWR@nulltextmd%
+\LetLtxMacro\textbf\LWR@nulltextbf%
+\LetLtxMacro\textrm\LWR@nulltextrm%
+\LetLtxMacro\textsf\LWR@nulltextsf%
+\LetLtxMacro\texttt\LWR@nulltexttt%
+\LetLtxMacro\textup\LWR@nulltextup%
+\LetLtxMacro\textit\LWR@nulltextit%
+\LetLtxMacro\textsc\LWR@nulltextsc%
+\LetLtxMacro\textsl\LWR@nulltextsl%
+\LetLtxMacro\textnormal\LWR@nulltextnormal%
+\LetLtxMacro\rmfamily\LWR@nullrmfamily%
+\LetLtxMacro\sffamily\LWR@nullsffamily%
+\LetLtxMacro\ttfamily\LWR@nullttfamily%
+\LetLtxMacro\bfseries\LWR@nullbfseries%
+\LetLtxMacro\mdseries\LWR@nullmdseries%
+\LetLtxMacro\upshape\LWR@nullupshape%
+\LetLtxMacro\slshape\LWR@nullslshape%
+\LetLtxMacro\scshape\LWR@nullscshape%
+\LetLtxMacro\itshape\LWR@nullitshape%
+\LetLtxMacro\em\LWR@nullem%
+\LetLtxMacro\normalfont\LWR@nullnormalfont%
 \renewcommand*{\,}{-}%
 \renewcommand*{~}{-}%
 \renewcommand*{\newline}{ }%
@@ -10638,8 +10841,9 @@ width:\LWR@printlength{\LWR@tempwidth}%
 \newlength{\LWR@tempheight}
 \newlength{\LWR@tempraise}
 
-\NewDocumentCommand{\LWR@hspace}{s m}{%
-\setlength{\LWR@tempwidth}{#2}%
+\newcommand{\LWR@select@html@hspace}{%
+\RenewDocumentCommand{\hspace}{s m}{%
+\setlength{\LWR@tempwidth}{##2}%
 \ifnum\gluestretchorder\LWR@tempwidth>0%
 \setlength{\LWR@tempwidth}{2em}%
 \fi%
@@ -10665,13 +10869,21 @@ width:\LWR@printlength{\LWR@tempwidth}%
     }%
     \LWR@minipagestartpars%
 }% width not 0
+}%
+}
+\newcommand{\LWR@select@html@nohspace}{%
+    \RenewDocumentCommand{\hspace}{s m}{}%
+}
+
+\newcommand*{\LWR@select@print@hspace}{%
+    \renewrobustcmd\hspace{\@ifstar\@hspacer\@hspace}%
 }
-\NewDocumentCommand{\LWR@nohspace}{s m}{}
 
-\LetLtxMacro\hspace\LWR@hspace
+\LWR@select@html@hspace
+
+\NewDocumentCommand{\LWR@HTML@vspace}{s m}{}
 
-\NewDocumentCommand{\LWR@vspace}{s m}{}
-\LetLtxMacro\vspace\LWR@vspace
+\LWR@formatted{vspace}
 
 \renewcommand*{\linebreak}[1][]{\newline}
 
@@ -10686,7 +10898,7 @@ width:\LWR@printlength{\LWR@tempwidth}%
 \RenewDocumentCommand{\enlargethispage}{s m}{}
 \renewcommand*{\clearpage}{}
 \renewcommand*{\cleardoublepage}{}
-\NewDocumentCommand{\LWR@rule}{o m m}{%
+\newcommand*{\LWR@HTML@rule}[3][]{%
 \setlength{\LWR@tempwidth}{#2}%
 \ifthenelse{\lengthtest{\LWR@tempwidth=0pt}}
 {}% zero- width
@@ -10703,13 +10915,15 @@ width:\LWR@printlength{\LWR@tempwidth}%
     }%
     {\setlength{\LWR@tempheight}{1pt}}{}%
     \LWR@minipagestoppars%
+    \LWR@findcurrenttextcolor%
     \LWR@htmltagc{%
     span
     style="%
     \ifbool{FormatWP}{}{background:\LWR@currenttextcolor ; }%
     width:\LWR@printlength{\LWR@tempwidth} ; %
     height:\LWR@printlength{\LWR@tempheight} ; %
-    \IfValueT{#1}%
+    \ifblank{#1}%
+    {}%
     {%
         \setlength{\LWR@tempraise}{0pt-#1}%
         \setlength{\LWR@tempraise}{\LWR@tempraise*2}%
@@ -10734,8 +10948,8 @@ width:\LWR@printlength{\LWR@tempwidth}%
     \LWR@minipagestartpars%
 }% non-zero width
 }
-\renewrobustcmd{\rule}{\LWR@rule}
 
+\LWR@formatted{rule}
 \end{warpHTML}
 
 
-- 
cgit v1.2.3

