% -----------------------------------------------------------------------
% webquiz.cfg | webquiz TeX4ht configuration file
% -----------------------------------------------------------------------
%
% Copyright (C) Andrew Mathas and Don Taylor, University of Sydney
%
% Distributed under the terms of the GNU General Public License (GPL)
% http://www.gnu.org/licenses/
%
% This file is part of the WebQuiz system.
%
%
% ----------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesFile{webquiz.cfg}[\webquiz{release date} v\webquiz{version} WebQuiz tex4ht configuration]
\makeatletter% quite surprisingly, this is needed!
% shortcut for inserting newlines into xml ifle
\newcommand\HNewLine{\HCode{\Hnewline}}
% Generate HTML5 + MathML code
\Preamble{xhtml,mathml,html5,NoFonts,charset="utf-8",ext=xml,svg}
% Don't output xml version tag
\Configure{VERSION}{}
% Output a WebQuiz doctype instead of the default for HTML5
\Configure{DOCTYPE}{\HCode{\Hnewline
}}
\ifWQ@Debugging\def\WQ@debugging{true}\else\def\WQ@debugging{false}\fi
% store the quiz specifications as attributes to
\Configure{HTML}{%
\HNewLine%
\Tg
\HNewLine%
\Tg\@title\Tg%
\HNewLine%
\Tg\WQ@breadcrumb\Tg%
\HNewLine%
\Tg\uos@name\Tg%
\HNewLine%
\Tg\uos@code\Tg%
\HNewLine%
\Tg\WQ@department\Tg%
\HNewLine%
\Tg\WQ@institution\Tg%
\HNewLine%
}{\Tg}
% reset all configurations
\Configure{HEAD}{}{}
\Configure{BODY}{}{}
\Configure{TITLE}{}{}
\Configure{TITLE+}{}
\Configure{thanks author date and}{}{}{}{}{}{}{}{}
\renewcommand{\maketitle}{}
% convert pictures to svg
\Configure{Picture}{.svg}
%\Configure{Picture*}{.svg}
%\Configure{textit}{\HCode{}\NoFonts}{\EndNoFonts\HCode{}}
%\Configure{textsf}{\HCode{}\NoFonts}{\EndNoFonts\HCode{}}
% The webquiz macros and environments need to write opening and closing tags to
% the xml file. Opening these tags is easy. To close them we use \WQ@closeXXX
% and \WQ@@closeXXX macros. Each time a tag is opened we \let the \WQ@closeTag
% macro to the corresponding \WQ@@close macro. The \WQ@@close macro closes the
% tag and then \let's the \WQ@closeTag macro to \relax. This allows us to use
% the \WQ@close macros at the start of the tag routines below, which results in
% fairly transparent and readable code.
% make the @close tags \relax initially
\let\WQ@closeTag\relax % closes \correct, \incorrect, \feedback, \whenRight and \whenWrong
\let\WQ@closeText\relax % closes text
% text tags - everything in wrapped inside ... tags
\def\WQ@openText{\Tg\HtmlParOff\HCode{}\HtmlParOn\Tg\HNewLine\global\let\WQ@closeText\relax}
% -----------------------------------------------------------------------
% discussion environment
% -----------------------------------------------------------------------
% discussion environments are number -1, -2, ... in the webquiz.js
\renewcommand\thediscussion{-\arabic{discussion}}
% inside a discussion environment any label defines two labels, the second of
% which is a label to the short-title for the discussion item. Of there are many
% labels this is slightly in efficient but, because of tex4ht magic, it proved
% too painful to extract the discussion number from the label.
\let\WQ@reallabel=\label
\newcommand\WQ@discussionLabel[1]{%
\WQ@reallabel{#1}%
\bgroup\let\@currentlabel\WQ@shortDiscussionTitle%
\WQ@reallabel{discussion-title-#1}%
\egroup%
}
% discussion environments
\RenewDocumentEnvironment{discussion}{O{Discussion}O{#1}}{%
\WQ@DiscussionStart%
\HNewLine%
\Tg\HNewLine
\Tg#1\Tg\HNewLine
\Tg#2\Tg\HNewLine
\Tg\HCode{}\Tg\HNewLine\Tg\HNewLine\WQ@DiscussionEnd}
% ---------------------------------------------------------------------------
% Cross referencing question and discussion environments
% ---------------------------------------------------------------------------
% tex4ht redefines the \ref internals so that r@
\Hnewline}}
\renewcommand\DisplayAsImage[2][]{%
\csletcs{real:#2}{#2}%
\NewConfigure{#2}{2}
\csdef{#2}##1{\Picture+[#1]{}\csuse{real:#2}{##1}\EndPicture}
\Configure{#2}{\Picture+[#1]{}}{\EndPicture}
}
\begin{document}
% disable \title after \begin{document}
\def\title{\WQ@Error{\@backslashchar title can only be used in the preamble}\@ehc}
% -----------------------------------------------------------------------
% making listing environment work with colour II
% - this code appears to break \color and \textcolor in the online manual
% -----------------------------------------------------------------------
%% this code is for processing the listing environments in the online manual
\ifdefined\lst@version
% from https://www.mail-archive.com/tex4ht@tug.org/msg00116.html
\let\savecolor\color
\NewConfigure{color}[2]{\def\a@color{#1}\def\b@color{#2}}
\def\color@@tmp#1{\a@color#1\b@color\savecolor{#1}\aftergroup\endspan}
\let\color\color@@tmp
\def\endspan{\Tg}
\Configure{color}{\HCode{}}
\ConfigureEnv{lstlisting}
{\let\color\savecolor
\ifvmode \IgnorePar\fi \EndP
\gHAdvance\listingN by 1
\HCode{}%
\gdef\start:LstLn{\HCode{