HTML mode
glu can convert HTML files directly to PDF. Unlike Markdown mode, no default stylesheet is applied — all styling comes from <style> tags, <link> stylesheets, inline styles, or the --css flag.
glu page.html # → page.pdfglu detects the mode by the file extension: .html or .htm for HTML mode.
Features
HTML mode supports:
- Full HTML document structure (
<!DOCTYPE html>,<html>,<head>,<body>) <style>tags in<head>(including@pagerules)<link rel="stylesheet">for external CSS files- CSS class and element selectors
- Borders, padding, background colors, border-radius
- Tables, lists, headings, paragraphs
- Inline styles
Example
<!DOCTYPE html>
<html>
<head>
<style>
@page { size: a5; margin: 2cm; }
body { font-family: serif; font-size: 10pt; }
h1 { color: #336699; font-size: 20pt; }
.highlight {
border: 1pt solid #336699;
padding: 6pt;
border-radius: 3pt;
}
</style>
</head>
<body>
<h1>Report</h1>
<p>This PDF was generated from an HTML file.</p>
<div class="highlight">
<p>This section has a <strong>blue border</strong>.</p>
</div>
</body>
</html>Run with:
glu report.html # → report.pdfConformance level and document metadata
HTML has no frontmatter, so an HTML document declares its PDF
conformance level and title inline — in the <head>:
<head>
<meta name="pdf-format" content="PDF/UA-2">
<title>Quarterly report</title>
</head><meta name="pdf-format" content="…">sets the conformance level (PDF/UA,PDF/UA-2,PDF/A-3b, …) — the HTML equivalent of the Markdown frontmatterformat:key. With it, a bareglu report.htmlproduces the tagged PDF directly; no flag needed.<title>becomes the PDF document title (/Titleand, for PDF/UA, the XMPdc:titleplus/DisplayDocTitle).
The --format command-line flag overrides the meta tag when both are
present:
glu --format PDF/UA-2 report.htmlPrecedence is --format flag › <meta> tag › none.
Mathematics (MathML)
<math> elements are typeset through the OpenType-MATH engine. Point
the element at a font carrying an OpenType MATH table and embed the
formula inline:
<head>
<meta name="pdf-format" content="PDF/UA-2">
<title>MathML demo</title>
<style>
@font-face { font-family: "LM Math"; src: url("latinmodern-math.otf"); }
math { font-family: "LM Math"; font-size: 12pt; }
</style>
</head>
<body>
<p>The quadratic formula
<math>
<mi>x</mi><mo>=</mo>
<mfrac>
<mrow><mo>-</mo><mi>b</mi><mo>±</mo>
<msqrt><msup><mi>b</mi><mn>2</mn></msup><mo>-</mo>
<mn>4</mn><mi>a</mi><mi>c</mi></msqrt></mrow>
<mrow><mn>2</mn><mi>a</mi></mrow>
</mfrac>
</math>
solves a quadratic equation.</p>
</body>Under PDF/UA each formula becomes a tagged Formula element; under
PDF/UA-2 the MathML is additionally embedded as an associated file for
assistive technology. See Mathematics (MathML) for
the supported elements and
PDF/UA tagging for the
accessibility details.
Companion Lua file
Like Markdown mode, a companion Lua file is loaded automatically if it exists:
page.html ← your document
page.lua ← loaded automatically (if present)The companion file can register callbacks for page backgrounds, overlays, or element processing.
local frontend = require("glu.frontend")
frontend.add_callback("page_init", "bg", function(doc, page, pagenum, pageinfo)
-- draw page background
end)Custom CSS via command line
Additional CSS can be loaded with the --css flag:
glu --css extra.css page.htmlCSS from the command line is applied after stylesheets from <link> and <style> tags.
Page counters and auxiliary files
HTML mode supports the same page counters, auxiliary file, and _aux table as Markdown mode. Use counter(page) and counter(pages) in @page margin boxes:
<style>
@page {
@bottom-center {
content: counter(page) " / " counter(pages);
font-size: 9pt;
}
}
</style>See Markdown mode — Page margin boxes and counters for the full documentation.
Leaders (CSS)
Leaders create repeating dot patterns that fill available space — commonly used in table-of-contents entries. Use the CSS content: leader('.') property (from the CSS Generated Content for Paged Media specification) on an empty inline element:
<style>
.toc-entry { margin-top: 2pt; margin-bottom: 2pt; }
</style>
<p class="toc-entry">
Chapter 1<span style="content: leader('.')"></span>5
</p>
<p class="toc-entry">
Chapter 2<span style="content: leader('.')"></span>12
</p>This produces:
Chapter 1 . . . . . . . . . . . . 5
Chapter 2 . . . . . . . . . . . . 12The dots are vertically aligned across lines (global grid alignment). The leader pattern can be any string — leader('.') for dots, leader('_') for underscores, etc.
The <span> must be empty (no child content). The content property is parsed from the inline style attribute.
Barcodes
glu can generate barcodes directly as vector graphics in the PDF — no external images needed. Use the <barcode> element in HTML or Markdown:
<barcode type="code128" value="ABC-123" width="4cm" height="1cm"/>Supported types
| Type | Attribute value | Description |
|---|---|---|
| EAN-13 | ean13 |
13-digit product barcode |
| Code 128 | code128 |
Variable-length alphanumeric barcode |
| QR Code | qr |
2D matrix barcode |
Attributes
| Attribute | Required | Description |
|---|---|---|
type |
yes | Barcode type (ean13, code128, qr) |
value |
yes | The data to encode |
width |
no | Width (default: 3cm) |
height |
no | Height (default: same as width). For QR codes, height is always equal to width. |
eclevel |
no | QR error correction level: L, M (default), Q, or H |
Examples
EAN-13 barcode:
<barcode type="ean13" value="4006381333931" width="4cm" height="2cm"/>QR code with high error correction:
<barcode type="qr" value="https://www.example.com" width="3cm" eclevel="H"/>In Markdown — since raw HTML is supported, the same element works directly:
# My Product
<barcode type="code128" value="PROD-42" width="5cm" height="1cm"/>
Scan the barcode above for product details.Differences from Markdown mode
| Feature | Markdown mode | HTML mode |
|---|---|---|
| Default stylesheet | Built-in (serif, A4, margins) | None — you provide all CSS |
| Frontmatter | YAML (title, author, etc.) |
Not supported |
| Lua blocks | ```{lua} |
Not supported (use companion .lua) |
| Inline expressions | {= expr =} |
Not supported |
| Go templates | --template flag |
Not supported |
@page rules |
Via frontmatter or CSS file | Via <style> or <link> |
HTML mode is ideal when you need full control over the document structure and styling, or when converting existing HTML content to PDF.