-
Notifications
You must be signed in to change notification settings - Fork 48
/
ht-latex
executable file
·37 lines (29 loc) · 2.29 KB
/
ht-latex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# set -x
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
MAIN_FILE="${1%.tex}"
OUTPUT_FOLDER="$2"
HTML_SETTINGS="${SCRIPT_DIR}/html-plain,fn-in,charset=utf-8"
ENCODING="-cunihtf -utf8"
mkdir -p $OUTPUT_FOLDER
echo Pre-Build With PDF Latex
pdflatex $MAIN_FILE || true
bibtex $MAIN_FILE
pdflatex $MAIN_FILE || true
pdflatex $MAIN_FILE
echo
echo Build With Latex and TEX4HT
latex $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 '$HTML_SETTINGS'.a.b.c.\input ' $MAIN_FILE
#latex $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 '$HTML_SETTINGS'.a.b.c.\input ' $MAIN_FILE
#latex $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 '$HTML_SETTINGS'.a.b.c.\input ' $MAIN_FILE
echo
echo Do Tex4HT
tex4ht -f/$MAIN_FILE -i~/tex4ht.dir/texmf/tex4ht/ht-fonts/ $ENCODING
t4ht -f/$MAIN_FILE -d$OUTPUT_FOLDER
echo
echo Run Tidy
cp $MAIN_FILE.html $OUTPUT_FOLDER/
tidy -ashtml -utf8 $OUTPUT_FOLDER/$MAIN_FILE.html > $OUTPUT_FOLDER/$MAIN_FILE-tidy.html || true
echo Run Post Process HTML
export PYTHONWARNINGS=ignore
$SCRIPT_DIR/post-process-html.py $OUTPUT_FOLDER/$MAIN_FILE-tidy.html > $OUTPUT_FOLDER/$MAIN_FILE-final.html