main text citet example: LastName [1900] main text
8 |main text(don’t forget the half-space, citep:) ctanchor [LastName, 1900]. text main.
9 |├── .github
└── workflows
│ └── ci.yml
├── .gitignore
├── README.md
├── ht-latex
├── html-plain.cfg
├── post-process-html.py
├── run-tests.py
└── tests
├── citation-001
├── expected.html
├── references.bib
└── test.tex
├── citation-002
├── expected.html
├── references.bib
├── result-test.
└── test.tex
├── citation-003
├── expected.html
├── references.bib
└── test.tex
├── citation-004
├── ACM-Reference-Format.bst
├── acmart.cls
├── expected.html
├── references.bib
└── test.tex
├── footnote-001
├── expected.html
└── test.tex
├── header-abstract-001
├── expected.html
└── test.tex
├── ligatures-001
├── expected.html
└── test.tex
├── listing-001
├── expected.html
└── test.tex
├── listing-002
├── expected.html
└── test.tex
├── resources
├── ACM-Reference-Format.bst
└── acmart.cls
├── sections-001
├── expected.html
├── references.bib
└── test.tex
└── special-chars-001
├── expected.html
└── test.tex
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on: [push, pull_request]
4 |
5 | jobs:
6 | build-and-test:
7 | runs-on: ubuntu-latest
8 | container:
9 | image: texlive/texlive:latest
10 | steps:
11 | - name: Set up Git repository
12 | uses: actions/checkout@v3
13 |
14 | - name: Install Dependencies
15 | run: |
16 | apt-get update
17 | apt-get install -y tidy python3-pip
18 | python -m pip install --break-system-packages beautifulsoup4 html5lib
19 |
20 | - name: Run Tests
21 | run: |
22 | python run-tests.py
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Test output files
2 | test.4ct
3 | test-final.html
4 | test-tidy.html
5 | test.4tc
6 | test.css
7 | test.dvi
8 | test.html
9 | test.idv
10 | test.html
11 | test.lg
12 | test.tmp
13 | test.xref
14 | test.pdf
15 | test.xcp
16 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | LaTeX to HTML5
2 | ==============
3 |
4 | This repository contains configuration files for tex4ht and post processing
5 | scripts to customize and simplify the HTML generated by tex4ht. Instead of
6 | preserving the full generality of LaTeX, it seems to be a better approach for
7 | the Web to concentrate on the semantic elements and provide a suitable CSS file.
8 |
9 |
10 | ### Requirements
11 |
12 | - tex4ht aka htlatex
13 | - tidy, see https://www.html-tidy.org/
14 | - Python, and packages via `pip install`
15 | - BeautifulSoup4
16 | - html5lib
17 |
18 | ### Usage
19 |
20 | ```
21 | $ ht-latex tex-file output-dir
22 | ```
23 |
24 | The output file is going to be `tex-file-final.html`.
25 |
26 | ### Examples
27 |
28 | - http://stefan-marr.de/papers/pldi-marr-et-al-zero-overhead-metaprogramming/
29 | - http://stefan-marr.de/papers/oopsla-marr-ducasse-meta-tracing-vs-partial-evaluation/
30 |
31 | ### Status and Contributions
32 |
33 | The current status of this project is: *highly experimental and optimized for
34 | myself*, ah, and of course, it works on my machine...
35 |
36 | Pull requests to improve the situation are very welcome.
37 |
38 | ### Tests
39 |
40 | There are a couple of basic tests in `tests`, which can be executed with
41 | `run-tests.py`.
42 |
43 | ### License
44 |
45 | This project is licensed under the MIT license: https://opensource.org/licenses/MIT
46 |
--------------------------------------------------------------------------------
/ht-latex:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | # set -x
3 |
4 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
5 |
6 | MAIN_FILE="${1%.tex}"
7 | OUTPUT_FOLDER="$2"
8 | HTML_SETTINGS="${SCRIPT_DIR}/html-plain,fn-in,charset=utf-8"
9 | ENCODING="-cunihtf -utf8"
10 |
11 | mkdir -p $OUTPUT_FOLDER
12 |
13 | echo Pre-Build With PDF Latex
14 | pdflatex $MAIN_FILE || true
15 | bibtex $MAIN_FILE
16 | pdflatex $MAIN_FILE || true
17 | pdflatex $MAIN_FILE
18 |
19 | echo
20 | echo Build With Latex and TEX4HT
21 | 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
22 | #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
23 | #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
24 |
25 | echo
26 | echo Do Tex4HT
27 | tex4ht -f/$MAIN_FILE -i~/tex4ht.dir/texmf/tex4ht/ht-fonts/ $ENCODING
28 | t4ht -f/$MAIN_FILE -d$OUTPUT_FOLDER
29 |
30 | echo
31 | echo Run Tidy
32 | cp $MAIN_FILE.html $OUTPUT_FOLDER/
33 | tidy -ashtml -utf8 $OUTPUT_FOLDER/$MAIN_FILE.html > $OUTPUT_FOLDER/$MAIN_FILE-tidy.html || true
34 |
35 | echo Run Post Process HTML
36 | export PYTHONWARNINGS=ignore
37 | $SCRIPT_DIR/post-process-html.py $OUTPUT_FOLDER/$MAIN_FILE-tidy.html > $OUTPUT_FOLDER/$MAIN_FILE-final.html
38 |
--------------------------------------------------------------------------------
/html-plain.cfg:
--------------------------------------------------------------------------------
1 | \Preamble{xhtml}
2 |
3 | \RequirePackage{ifthen}
4 |
5 | \ifthenelse{\isundefined{\citeurl}}{}{
6 | \renewcommand{\citeurl}[5]{\HCode{}#1\HCode{}}
7 | }
8 |
9 | % \renewcommand{\code}[1]{\lstinline!#1!}
10 | % \renewcommand{\java}[1]{\code{#1}}
11 | % \renewcommand{\py}[1]{\code{#1}}
12 | % \renewcommand{\stcode}[1]{\code{#1}}
13 | % \renewcommand{\rbcode}[1]{\code{#1}}
14 |
15 | % \def{\code}[1]{\lstinline!#1!}
16 | % \def{\java}[1]{\code{#1}}
17 | % \def{\py}[1]{\code{#1}}
18 | % \def{\stcode}[1]{\code{#1}}
19 | % \def{\rbcode}[1]{\code{#1}}
20 |
21 | \renewcommand{\textit}[1]{\HCode{}#1\HCode{}}
22 | \renewcommand{\textbf}[1]{\HCode{}#1\HCode{}}
23 | \renewcommand{\emph}[1]{\HCode{}#1\HCode{}}
24 | \renewcommand{\texttt}[1]{\HCode{}#1\HCode{
}}
25 | \renewcommand{\textbackslash}{\HCode{!!TEXTBACKSLASH!!}}
26 |
27 | \Configure{()}{\HCode{}}{\HCode{}}
28 | % \Configure{footnote}{\HCode{FOT1}}{\HCode{FOT2}}
29 | \Configure{footnote}{}{}{}{}
30 | \Configure{footnotetext}{\HCode{}}{}{\HCode{}}
31 | \Configure{footnotemark}{}{}
32 |
33 |
34 | \Configure{section}{\HCode{
}}{\EndP\HCode{
}}{\HCode{
}}{\HCode{}} 37 | \Configure{caption}{\HCode{}}{\HCode{
}}
52 | \ConfigureEnv{lstlisting}
53 | {\ifvmode \IgnorePar\fi \EndP
54 | \gHAdvance\listingN by 1
55 | \gdef\start:LstLn{%
56 | \HCode{}%
57 | \gdef\start:LstLn{\leavevmode\special{t4ht@+\string&{35}x000A{59}}x}}%%% this special string thing inserts an HTML entity for a newline... didn't find another way
58 | \bgroup
59 | \Configure{listings}
60 | {{\everypar{}\leavevmode}}
61 | {{\everypar{}\leavevmode}}
62 | {\start:LstLn }
63 | {}%
64 | }
65 | {\egroup
66 | \ifvmode \IgnorePar\fi \EndP \HCode{
main text citet example: LastName [1900] main text
8 |main text(don’t forget the half-space, citep:) ctanchor [LastName, 1900]. text main.
9 |citet example: LastName [1900], LastName1 8 | et al. [2005, 2013].
9 |ctanchor [LastName, 1900, LastName1 10 | et al., 2005, 2013].
11 |citet example: LastName [1900].
12 |ctanchor [LastName, 1900].
13 |citet example: LastName [1900], LastName1 14 | et al. [2005].
15 |ctanchor [LastName1 16 | et al., 2005, 2013].
17 |F. LastName. 20 | TitleTag. PublisherTag, AddressTag, 1900. ISBN 21 | IsbnTag.
22 |F. LastName1, 23 | F. LastName2, and F. LastName3. Title. In 24 | BookTitle, Series, pages 439–453. ACM, 2005. ISBN Isbn. 25 | doi: Doi.
26 |F. LastName1, 27 | F. LastName2, and F. LastName3. Title. Journal, 28 | 45(4): 1–4, Aug. 2013. ISSN Issn. doi: Doi. URL http://url.
29 |has been recognized as an issue [Haller, 2015, Swalens 8 | et al., 2014, Tasharofi 9 | et al., 2013], the question of how to
10 |P. Haller. High-Level 13 | Concurrency Libraries: Challenges for Tool Support, 2015.
14 |J. Swalens, 15 | S. Marr, J. De Koster, and T. Van Cutsem. 16 | Towards composable concurrency abstractions. In Proc. of the 17 | PLACES Workshop, volume 155, 2014.
18 |S. Tasharofi, 19 | P. Dinges, and R. E. Johnson. Why do scala developers mix 20 | the actor model with other concurrency models? In ECOOP 2013 – 21 | Object-Oriented Programming, volume 7920. 2013.
22 |Test
9 |ACM Reference 10 | Format:
11 |. 2023. Test. 12 | In Proceedings 13 | of ACM Conference (Conference’17). ACM, 14 | New York, NY, 15 | USA , 16 | 1 page. https://doi.org/\@acmDOI
17 |Marr and Ducasse [1] 19 | References
20 |[1] Stefan 22 | Marr and Stéphane 23 | Ducasse. 2015. 24 | Tracing vs. Partial Evaluation: Comparing Meta-Compilation 25 | Approaches for 26 | Self-Optimizing Interpreters. In Proceedings of the 27 | 2015 ACM International 28 | Conference on Object Oriented Programming Systems Languages & 29 | Applications (OOPSLA ’15). ACM, 821–839. https://doi.org/10.1145/2814270.2814275
30 |main text main text main text main text ftanchor1 1Some footnote text
8 | 9 | 10 |abstract abstract abstract abstract abstract 15 | abstract abstract abstract abstract 16 | abstract abstract abstract abstract abstract abstract 17 | abstract abstract abstract abstract 18 | abstract abstract abstract abstract abstract
19 |main text main text main text main text main text main text main 24 | text main text
25 |Test ligatures:
8 |ff fi fl ffi ffl
9 |Œ œ Æ æ
10 |IJ ij
11 | 12 | 13 |main text main foobar
.
main text before
8 |main text after
19 | 20 | 21 |