Skip to content

Commit 14587e9

Browse files
committed
Generate HTML via make4ht
This patch add some scripts which are meant to generating html files successfully with make4ht. The target is to build a directory html/ for github page deployment usuage. Problems : When you try using `make4ht -suf html5 -d html lkmpg.tex` to parse the file, you'll find out that make4ht has several defectors: 1. The layout is unsatisfying 2. When it parsing lkmpg.tex and meet \tableofcontents will throw error 3. It generated a lot unneeded files when parsing lkmpg.tex 4. The output filenames are based on input filename and you can't assign them, which is inconvinient cause github page will only recognize the file named `index.html`. Solutions : For problem 1, we can write a config file `html.cfg` to specify the layout style of lkmpg.html with css selectors. For problem 2, we can turn off the \tableofcontents section when using make4ht. However, this cause the output html files without table of contents part. And we can fix this by adding `\Configure{tableofcontents*}{chapter,section,subsection}` into html.cfg so the output html files will contain table of contents again. For problem 3, we can add some delete commands into Makefile. For problem 4, we can add a symbolic link `index.html` lined to `lkmpg.html` Overview of file changes : In html.cfg : Specify the layout of lkmpg.html. Add tables of contents. In Makefile : Add a new target `html` for generating html files and put them in html/ directory. Add a symbolic link `index.html` linked to `lkmpg.html`. Add several `rm` command to get rid of unneeded files. In lkmpg.tex : Turn off the \tableofcontens section when using `make4ht` to prevent from error.
1 parent 4639ca1 commit 14587e9

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@ _minted-lkmpg
1515
*.out
1616
lkmpg.pdf
1717
*.toc
18+
19+
# make4ht
20+
*.html
21+
*.svg
22+
*.tmp
23+
*.css
24+
*.4ct
25+
*.4tc
26+
*.dvi
27+
*.lg
28+
*.idv
29+
*.xref

Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ all: lkmpg.tex
44
bibtex main >/dev/null || echo
55
pdflatex -shell-escape $< 2>/dev/null >/dev/null
66

7+
html: lkmpg.tex html.cfg
8+
make4ht --shell-escape --utf8 --format html5 --config html.cfg --output-dir html lkmpg.tex
9+
ln -sf lkmpg.html html/index.html
10+
rm -f lkmpg.xref lkmpg.tmp lkmpg.html lkmpg.css lkmpg.4ct lkmpg.4tc lkmpg.dvi lkmpg.lg lkmpg.idv lkmpg*.svg lkmpg.log lkmpg.aux
11+
712
clean:
813
rm -f *.dvi *.aux *.log *.ps *.pdf *.out lkmpg.bbl lkmpg.blg lkmpg.lof lkmpg.toc
914
rm -rf _minted-lkmpg
15+
rm -rf html
16+
17+
.PHONY: html

html.cfg

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
\Preamble{xhtml}
2+
3+
\Configure{tableofcontents*}{chapter,section,subsection}
4+
5+
\Css{* :not(img) {
6+
max-width: 100\%;
7+
width: 50vw;
8+
height: auto;
9+
margin: 0 auto;
10+
}}
11+
12+
\Css{* {
13+
font-size: 1vw;
14+
}}
15+
16+
\Css{.ecrm-0500 {
17+
font-size: 70\%;
18+
font-style: italic;
19+
color: gray;
20+
-webkit-user-select: none;
21+
-moz-user-select: none;
22+
-o-user-select: none;
23+
user-select: none;
24+
}}
25+
26+
\Css{.ecrm-0500:after {
27+
content:" ";
28+
white-space: pre;
29+
-webkit-user-select: none;
30+
-moz-user-select: none;
31+
-o-user-select: none;
32+
user-select: none;
33+
}}
34+
35+
\begin{document}
36+
\EndPreamble

lkmpg.tex

+4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@
3939
\begin{document}
4040

4141
\maketitle
42+
\ifdefined\HCode
43+
% turn off TOC
44+
\else
4245
\tableofcontents
46+
\fi
4347

4448
\section{Introduction}
4549
\label{sec:introduction}

0 commit comments

Comments
 (0)