HtmLaTeX
Work in Progress
Like HTML, but not LaTeX? HtmLaTeX compiles HTML code to LaTeX.
For example, the following HTML code:
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My Paper</title>
<meta name="date" content="2022-09-02">
<meta name="author" content="Linus">
<link rel="icon" type="image/png" href="logo.png">
</head>
<body>
<div>
<a href="#">link</a>
</div>
<h1 id="section-1">Hello World</h1>
<p>This is a paragraph.</p>
<img src="a">
</body>
</html>
...compiles to the following LaTeX code:
%%%%%% HEAD START %%%%%%
\title{My Paper}
\date{2022-09-02}
\author{Linus}
%%%%%% HEAD END %%%%%%
%%%%%% MAIN DOCUMENT START %%%%%%
\begin{document}
\maketitle
\section{Hello World}
\label{section-1}
This is a paragraph.
\includegraphics{a}
\end{document}
%%%%%% MAIN DOCUMENT END %%%%%%
Installation
$ pip install HtmLaTeX
Usage
As binary
$ python3 -m htmlatex paper.html
This will create a file called paper.tex in the current directory.
As library
import io
import bs4
from htmlatex import Handlers, htmlatex
# Declare handlers for HTML tags
# Collection of handlers for HTML tags
handlers = Handlers()
# Register a handler for the <h1> tag
@handlers.register()
def h1(node: bs4.element.Tag):
section_name = node.string
section_id = node.attrs['id']
yield [
r"\section{%s}" % section_name,
r"\label{%s}" % section_id,
]
# ... more handlers ...
# Destination for generated LaTeX
generated_latex = io.StringIO()
# HTML to be converted
html = "..."
# And compile
htmlatex(html, generated_latex, handlers=handlers)
Metadata
Release files for htmlatex 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| HtmLaTeX-0.1.0.tar.gz | 3.3 kB | Without provenance | Details for HtmLaTeX-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| HtmLaTeX-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for HtmLaTeX-0.1.0-py3-none-any.whl |
Total release size: 6.9 kB
Release files / HtmLaTeX-0.1.0.tar.gz
| Download URL | HtmLaTeX-0.1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f0bb482c0c4908e1491a6bfaf7a4219421f4b42725e7ddcf807bf8d2fe924c6
|
|
BLAKE2b-256 checksum How to use checksums |
4488f570cdd5b9b2c896fb5aa32b9350914019a0be342c4fef41b7c9de9e167c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.10 Linux/5.15.0-41-generic
|
Release files / HtmLaTeX-0.1.0-py3-none-any.whl
| Download URL | HtmLaTeX-0.1.0-py3-none-any.whl |
|---|---|
| Size | 3.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c2e5493ea813a3f24ee91cef86d6289a171379038cc65ba7cfba2de40fc3a7fd
|
|
BLAKE2b-256 checksum How to use checksums |
b7efa3a68259c5a6b99367de78c8190a299ff24f7b7b692b4600934ca9e8b93f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.13 CPython/3.8.10 Linux/5.15.0-41-generic
|
Security for htmlatex 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.