#!/bin/sh

# Replacement for latex executable when latexmk is used for htlatex
# See TeX4ht-latexmkrc in the example-rcfiles directory of the latexmk
# distribution for how to use this.
#
# This is a shell script suitable for UNIX-like operating systems (including
# OS-X and linux, and presumably Cygwin under MS-Windows).

latex --recorder $5 '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1,html]{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1,html}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode '$2'.a.b.c.\input ' $1
