From 01eb67d5937cb27e420adefd0dfc9d802b8061b9 Mon Sep 17 00:00:00 2001 From: Chris Spiel Date: Mon, 9 Nov 2020 09:55:48 +0100 Subject: [PATCH 1/4] Add internal macro `\print@endline' which behaves like `\@print', but adds an endline character to the output. Update the documentation accordingly. --- doc/text.tex | 6 +++++- latexscan.mll | 7 +++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/text.tex b/doc/text.tex index 08bcffe7..bc099115 100644 --- a/doc/text.tex +++ b/doc/text.tex @@ -2726,6 +2726,7 @@ \subsection{Internal \label{internal}macros} \index{"@print@\texttt{\char92"@print}|defocc} +\index{"@print"@endline@\texttt{\char92"@print"@endline}|defocc} \index{"@getprint@\texttt{\char92"@getprint}|defocc} \index{"@print"@u@\texttt{\char92"@print"@u}|defocc} \index{"@hr@\texttt{\char92"@hr}|defocc} @@ -2739,7 +2740,7 @@ \subsection{Internal \label{internal}macros} \index{"@fontsize@\texttt{\char92"@fontsize}|defocc} \index{"@fontcolor@\texttt{\char92"@fontcolor}|defocc} It is important to notice that primitive arguments \emph{are} -processed (except for the \verb+\@print+~primitive, and for some of +processed (except for the \verb+\@print+~primitives, and for some of the basic style primitives). Thus, some characters cannot be given directly (e.g. \verb+#+ and \verb+%+ must be given as \verb+\#+ and \verb+\%+). @@ -2749,6 +2750,9 @@ \subsection{Internal \label{internal}macros} \textit{text} verbatim. As a consequence use only ASCII in \textit{text}. +\item[{\tt\char92 @print@endline\char123}{\it text}{\tt\char125}] Same + as \verb+\@print+ but appends a newline character to the output. + \item[{\tt\char92 @getprint\char123}{\it text}{\tt\char125}] Process \textit{text} using a special output mode that strips off \html~tags. This macro is the one to use for processed attributes diff --git a/latexscan.mll b/latexscan.mll index 44914729..3698bbe7 100644 --- a/latexscan.mll +++ b/latexscan.mll @@ -2382,6 +2382,13 @@ def_code "\\@print" Dest.put arg) ;; +def_code "\\@print@endline" + (fun lexbuf -> + let {arg=arg} = save_arg lexbuf in + Dest.put arg; + Dest.put_char '\n') +;; + let put_unicode_default uc = try let txt = OutUnicode.get_default uc in From a5666fe9d71d5b1b316692c1760087efac14bf69 Mon Sep 17 00:00:00 2001 From: Chris Spiel Date: Mon, 9 Nov 2020 10:16:26 +0100 Subject: [PATCH 2/4] Make use of novel macro `\@print@endline' to simplify hva-files. --- chapterbib.hva | 4 +- html/hevea.hva | 97 ++++++++++++++++++-------------------------- html/symb-mathml.hva | 11 ++--- labeltype.hva | 3 +- latexcommon.hva | 12 +++--- spaces.hva | 3 +- 6 files changed, 53 insertions(+), 77 deletions(-) diff --git a/chapterbib.hva b/chapterbib.hva index 0fd3caf3..800e220e 100644 --- a/chapterbib.hva +++ b/chapterbib.hva @@ -1,8 +1,8 @@ \let\chapterbib@include\include \newcounter{chap@included} \newcommand{\maketocbibitem}{} -\newcommand{\@sectionbib@maketocbibitem}{\@auxdowrite{\@print{\@addcontentsline{htoc}}\{0\}\{\@print{\ahrefloc}\{bib:chap\thechap@included\}\{\refname{}\}\}\@print{ -}}} +\newcommand{\@sectionbib@maketocbibitem}{% + \@auxdowrite{\@print{\@addcontentsline{htoc}}\{0\}\{\@print{\ahrefloc}\{bib:chap\thechap@included\}\{\refname{}\}\}\@print@endline{}}} \renewcommand{\include}[1] {\stepcounter{chap@included}% \def\chapterbib@include@name{#1}% diff --git a/html/hevea.hva b/html/hevea.hva index a9a29477..bbadb020 100644 --- a/html/hevea.hva +++ b/html/hevea.hva @@ -12,14 +12,12 @@ % Linking to external style sheets \newtokens{\css@link}% \newcommand{\addcssfile}[1]{\addtokens{\css@link}{#1}}% -\newcommand{\loadcssfile}[1]{\addcssfile{\@print{<}\@getprint{link rel="stylesheet" type=\char34 text/css\char34\@print{ }href=\char34#1\char34\char62\@print{ -}}}}% +\newcommand{\loadcssfile}[1]{\addcssfile{\@print{<}\@getprint{link rel="stylesheet" type=\char34 text/css\char34\@print{ }href=\char34#1\char34\char62\@print@endline{}}}}% %%%%%% % Styles definition in the element \newtokens{\hevea@css}% \newcommand{\addstyle}[1]{\addtokens{\hevea@css}{#1}}% -\newcommand{\newstyle}[2]{\addstyle{\@getprint{#1\char123#2\char125\@print{ -}}}}% +\newcommand{\newstyle}[2]{\addstyle{\@getprint{#1\char123#2\char125\@print@endline{}}}}% \newif\ifexternalcss\externalcssfalse % %%Style attributes are normaly set through an indirection. @@ -82,11 +80,9 @@ \newcommand{\htmlfoot}[1]{\sbox{\@htmlfoot}{#1}} \newcommand{\htmlprefix}[1]{\sbox{\@htmlprefix}{#1}} \AtEndDocument -{\@close@par{\@nostyle\@print{ -}}% +{\@close@par{\@nostyle\@print@endline{}}% \usebox{\@htmlfoot}% -{\@nostyle\@print{ -}}} +{\@nostyle\@print@endline{}}} %%%%% Footnotes, html dependant part \newcommand{\@noteref}[4]{\@locnameref{#2#3}{#1#3}{#4}} \newcommand{\@notepointer}[3]{\@locref{#1#2}{#3}} @@ -109,13 +105,13 @@ \newstyle{.footnoterule}{margin:1em auto 1em 0px;width:50\%;} \newcommand{\footnoterule}{\@hr[\envclass@attr{footnoterule}]{}{}} \newenvironment{thefootnotes}[2][] - {\@out@par{{\@nostyle\@print{ -}}}\footnoterule% - \setlistclass{thefootnotes}% - \begin{list}{}{\renewcommand{\makelabel}[1]{##1}}} - {\end{list}\@out@par{{\@nostyle\@print{ - -}}}} + {\@out@par{{\@nostyle\@print{}}}\footnoterule% + \setlistclass{thefootnotes}% + \begin{list}{}{\renewcommand{\makelabel}[1]{##1}}} + {\end{list}\@out@par{{\@nostyle\@print@endline{ +}}}} %%% Captions html dependent part \newstyle{.caption} {padding-left:2ex; padding-right:2ex; margin-left:auto; margin-right:auto} @@ -130,8 +126,7 @@ \newcommand{\cutdef*}[2][] {\@out@par{{\@nostyle\@print{}}}} \newcommand{\cutend*} -{\@out@par{{\@nostyle\@print{ -}}}} +{\@out@par{{\@nostyle\@print@endline{}}}} %%% New cutdef/cutend, with footnote managment \hva@newstack{@foot} \newcommand{\cutdef}[2][]{% @@ -139,8 +134,7 @@ \@out@par{{\@nostyle\@print{}}}} \newcommand{\cutend}{% \footnoteflush{\@footnotelevel}% -\@out@par{{\@nostyle\@print{ -}}}% +\@out@par{{\@nostyle\@print@endline{}}}% \@endfootnotesub\@pop@foot{\@footnotelevel}} %%%Close/Re-open toplevel pars \newcommand{\@secbegin}{\@close@par} @@ -151,8 +145,7 @@ \@footnoteflush{#1}% {\@out@par{{\@nostyle\@print{ -}}}}} +\begin{@norefs}#2\end{@norefs}{\@nostyle\@print@endline{-->}}}}} \newcommand{\@hacha@arg}[2] {{\@nostyle\@print{}{#2}\@print{}}} \newenvironment{@cutflow}[2] @@ -166,8 +159,7 @@ \newenvironment{cutflow}[1]{\begin{@cutflow}{YES}{#1}}{\end{@cutflow}} \newenvironment{cutflow*}[1]{\begin{@cutflow}{NO}{#1}}{\end{@cutflow}} \newcommand{\cutname}[1] -{\@out@par{{\@nostyle\@print{ -}}}} +{\@out@par{{\@nostyle\@print{}}}} \newcommand{\@link@arg}[2] {\ifthenelse{\equal{#2}{}}{} {\@hacha@arg{#1}{#2}}} @@ -217,14 +209,14 @@ {\@forcecommand{#1}{\begin{toimage}#1\end{toimage}#2}} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% \maketitle (is no longer redefined by fancysection) % -% Thus defining different styles explicitly will have to % -% be done using the respective classes : % +% \maketitle (is no longer redefined by fancysection) % +% Thus defining different styles explicitly will have to % +% be done using the respective classes : % % .title : table containing the title and supplements % -% .titlemain : h1 containing title name % +% .titlemain : h1 containing title name % % .titlerest : h3 containing other fields (author,date,etc.)% % 'checkbox' now takes three instead of two arguments, % -% one for the class. % +% one for the class. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \newcommand{\title@tohaux}[1] @@ -282,45 +274,36 @@ \@getprint{\@charset}% \@print{"> -}% +\@getprint{\usebox{\@heveaversion}}\@print@endline{">}% \ife\hevea@css\else \ifexternalcss\loadcssfile{\hva@dump@css}\else \@print{ -}\fi\fi +\hevea@css\@print@endline{}\fi\fi \ife\css@link\else\css@link\fi \undef\hevea@css\undef\newstyle} \newenvironment{document}{% \@end{document}% \@atbegindocument% \@restartoutput\unskip% -\@print{ -}\@print{ +\@print@endline{}% +\@print{ } \@meta% \@print{}% \ifu\@title\jobname\else \@notags{\begin{@norefs}\let\@print@u\@print@u@default\@getprint{\@title}\end{@norefs}} \fi -\@print{ -}% -\ifmathml\@print{ -}\fi -\@print{ -}% -\@print{ -}% -\@print{ -}% +}\fi +\@print@endline{}% +\@print{}% +\@print{}% {\@nostyle\@print{}}% -\ife\@htmlhead\else{\@nostyle\@print{ -}}% +\ife\@htmlhead\else{\@nostyle\@print@endline{}}% \usebox{\@htmlhead}% -{\@nostyle\@print{ -}}\fi% +{\@nostyle\@print@endline{}}\fi% \ife\@htmlprefix\else\@printnostyle{ @@ -336,9 +319,9 @@ \@atenddocument% \@final@footer% \@clearstyle% -\@print{ - -}\@raise@enddocument} +\@print@endline{ +}% +\@raise@enddocument} \newstyle{.center}{text-align:center;margin-left:auto;margin-right:auto;}% \newstyle{.flushleft}{text-align:left;margin-left:0ex;margin-right:auto;}% \newstyle{.flushright}{text-align:right;margin-left:auto;margin-right:0ex;}% @@ -578,16 +561,16 @@ \newcommand{\@table@attributes@border}{style="border-spacing:0" class="cellpadding1"} % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Redefining \textoverline of latexcommon.hva % -% Here we can use HTML primitives % +% Redefining \textoverline of latexcommon.hva % +% Here we can use HTML primitives % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \newcommand{\overlinedbox}[1]% - {{\@styleattr{span}{style="text-decoration:overline"}#1}}% + {{\@styleattr{span}{style="text-decoration:overline"}#1}}% \renewcommand{\textoverline}[1]{\overlinedbox{#1}}% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% Redefining \fbox of latexcommon.hva % -% Here we can use HTML primitives % +% Redefining \fbox of latexcommon.hva % +% Here we can use HTML primitives % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \newstyle{.lrbox}{box-sizing:border-box;display:inline-block;overflow:visible;white-space:nowrap;} \newstyle{.center-lrbox}{display:inline-block;margin-left:50\%;transform:translateX(-50\%);} diff --git a/html/symb-mathml.hva b/html/symb-mathml.hva index 4cbf93f8..81553ab5 100644 --- a/html/symb-mathml.hva +++ b/html/symb-mathml.hva @@ -47,20 +47,17 @@ % Roots \newcommand{\sqrt}[2][!*!]{\ifthenelse{\equal{#1}{!*!}}% -{\@print{ -}% +{\@print@endline{}% #2\@print{ }% -}{\@print{ -}\@open{display}{}% +}{\@print@endline{}\@open{display}{}% #2 \@close{display}{}% \@open{display}{}% #1% \@close{display}{}% -\@print{ - -}}} +\@print@endline{ +}}} % Ellipsis \renewcommand{\ldots}{\ifmath\@mop{TripleDot}\else{...}\fi} diff --git a/labeltype.hva b/labeltype.hva index 7eadecff..62606cd5 100644 --- a/labeltype.hva +++ b/labeltype.hva @@ -9,8 +9,7 @@ \let\@rt@old@label\label \renewcommand{\label}[2][] {\@rt@old@label[#1]{#2}% -\@auxdowrite{\@print{\@deflabeltype}\{#2\}\{\currentlabeltype\}\@print{ -}}} +\@auxdowrite{\@print{\@deflabeltype}\{#2\}\{\currentlabeltype\}\@print@endline{}}} %%Hum also redefines \enumerate... \let\@rt@oldenumerate\enumerate \renewcommand{\enumerate}{\def\currentlabeltype{item}\@rt@oldenumerate} diff --git a/latexcommon.hva b/latexcommon.hva index 5a955dcd..e01dde7b 100644 --- a/latexcommon.hva +++ b/latexcommon.hva @@ -85,7 +85,7 @@ \renewcommand{\@hevea@amper} {\ifthenelse{\value{@eqna@col}<2} {\stepcounter{@eqna@col}\@PAM} - {\hva@warn{Extra column in eqnarray}}} + {\hva@warn{Extra column in eqnarray}}} \renewcommand{\\}[1][]{\@eqna@complete\@PAM\@number\setcounter{@eqna@col}{0}\@yesnumber\stepcounter{equation}\@PBS} \@array{rclr}} {\\{}\addtocounter{equation}{-1}\end@array\]\@close{div}} @@ -227,11 +227,11 @@ \setcounter{\@itemcount}{0}} {\@close{OL}\addtocounter{enumcount}{-1}} % -%% Modified to support styles e.g. +%% Modified to support styles e.g. %%
, %%
%% ONLY CHANGES : 1) class=list added to \@open{DL} argument -%% 2) \@dt replaced by \@list@dtdd +%% 2) \@dt replaced by \@list@dtdd %% Remove these to get original behaviour % \newcommand{\setlistclass}[1] @@ -565,8 +565,7 @@ %}}} \newcommand{\@doaddtoc}[3] {%\stepcounter{tocanchor}% -\@auxdowrite{\@print{\@@addtocsec{htoc}}\{\@getprintnostyle{\@sec@id@attr}\}\{#1\}\{\@checkdepth{#1}{\@print{\@print}\{#2\}\@print{\quad{}}}\begin{@norefs}\@subst@expn{#3}\end{@norefs}\}\@print{ -}}} +\@auxdowrite{\@print{\@@addtocsec{htoc}}\{\@getprintnostyle{\@sec@id@attr}\}\{#1\}\{\@checkdepth{#1}{\@print{\@print}\{#2\}\@print{\quad{}}}\begin{@norefs}\@subst@expn{#3}\end{@norefs}\}\@print@endline{}}} %%section identifiers \newcounter{@sec} \newcommand{\@fmt@sec}{sec\arabic{@sec}} @@ -688,8 +687,7 @@ \@iffileexists{\jobname.#1}{\input{\jobname.#1}}{}} \newcommand{\tableofcontents}{\@readtoc{htoc}{\contentsname}} \newcommand{\addcontentsline}[3] -{\@auxdowrite{{\@nostyle\@print{\@addcontentsline}{\{h#1\}\{\csname @#2@level\endcsname\}}\{\@subst{#3}\}\@print{ -}}}} +{\@auxdowrite{{\@nostyle\@print{\@addcontentsline}{\{h#1\}\{\csname @#2@level\endcsname\}}\{\@subst{#3}\}\@print@endline{}}}} %%%%%%%%% Minipage %Manage footnotes in minipage, as latex does % 1. Use counter mpfootnote diff --git a/spaces.hva b/spaces.hva index 2017f69f..13ee979a 100644 --- a/spaces.hva +++ b/spaces.hva @@ -6,8 +6,7 @@ \def\!{} \def\;{\@print@u{8196}}% TeX: thick space: 5/18 quad; Unicode: emsp13, 6/18 quad! \def\ -{\@print{ -}} +{\@print@endline{}} \def\frenchspacing{} \def\nonfrenchspacing{} \def\/{} From f08c482ce179cdb59be7c99fb2ddec1842ba1b04 Mon Sep 17 00:00:00 2001 From: Chris Spiel Date: Mon, 9 Nov 2020 10:19:59 +0100 Subject: [PATCH 3/4] Fix HTML-code generation for `head' element according to vnu warnings. Reformat macro `\@meta' along the way. --- cut.mll | 5 ++--- html/hevea.hva | 47 +++++++++++++++++++++++++++++------------------ lexstyle.mll | 3 +-- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/cut.mll b/cut.mll index e2dbbe3f..9ca5191f 100644 --- a/cut.mll +++ b/cut.mll @@ -859,8 +859,7 @@ and collect_header = parse end} | '\n'? "']* '>' {skip_title lexbuf ; collect_header lexbuf} -| "' - '\n'? +| "}\fi\fi -\ife\css@link\else\css@link\fi -\undef\hevea@css\undef\newstyle} +\newcommand{\@meta}{% + \@print{}% + \@print{}% + \ife\hevea@css + \relax + \else + \ifexternalcss + \loadcssfile{\hva@dump@css}% + \else + \@print@endline{}% + \fi + \fi + \ife\css@link + \relax + \else + \css@link + \fi + \undef\hevea@css + \undef\newstyle +} \newenvironment{document}{% \@end{document}% \@atbegindocument% @@ -294,8 +305,8 @@ \@notags{\begin{@norefs}\let\@print@u\@print@u@default\@getprint{\@title}\end{@norefs}} \fi \@print@endline{}% -\ifmathml\@print@endline{}\fi \@print@endline{}% \@print{}% diff --git a/lexstyle.mll b/lexstyle.mll index 000f206d..3a1db645 100644 --- a/lexstyle.mll +++ b/lexstyle.mll @@ -70,8 +70,7 @@ and skip_comment = parse | "" { error "comment" lexbuf } and dump m out = parse -| "' '\n'? - as lxm +| "