Updating iA-writer section

This commit is contained in:
jostein 2026-03-26 10:15:02 +01:00
parent 6f50b1f00d
commit 37ba3383ba
7 changed files with 866 additions and 0 deletions

View file

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- Required identifiers -->
<key>CFBundleName</key>
<string>ExampleTemplate CleanDoc</string>
<key>CFBundleIdentifier</key>
<string>com.cleandoc.exampletemplate.v2</string>
<!-- Page files -->
<key>IATemplateDocumentFile</key>
<string>document</string>
<key>IATemplateTitleFile</key>
<string>title</string>
<key>IATemplateHeaderFile</key>
<string>header</string>
<key>IATemplateFooterFile</key>
<string>footer</string>
<!--
A4 margin model:
Top/bottom margins in PDF = header/footer height set here.
25 mm ≈ 71 CSS px at 96 dpi.
Header: 60 px (leaves room for a slim running title line)
Footer: 50 px (page number line + breathing room)
Left/right margin is controlled by max-width in style.css.
-->
<key>IATemplateHeaderHeight</key>
<integer>60</integer>
<key>IATemplateFooterHeight</key>
<integer>50</integer>
<!-- Title page gets NO header/footer — full bleed -->
<key>IATemplateTitleUsesHeaderAndFooterHeight</key>
<false/>
<key>IATemplateDescription</key>
<string>Clean Roboto document template for A4 PDF export with title page.</string>
<key>IATemplateAuthor</key>
<string>ExampleTemplate CleanDoc</string>
</dict>
</plist>

View file

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title><span data-title></span></title>
<link rel="stylesheet" href="style.css" />
<style>
/* Document page: no extra top/bottom padding.
Top/bottom white space comes from header/footer height in Info.plist. */
body {
padding-top: var(--sp-4);
padding-bottom: var(--sp-4);
}
/* The injected document content */
.document { }
</style>
</head>
<body>
<div class="document" data-document></div>
</body>
</html>

View file

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="style.css" />
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
max-width: 100%;
}
body {
display: flex;
align-items: flex-start; /* pin to top of footer zone */
padding: 10px 10vw 0;
}
.footer-inner {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
border-top: 1px solid var(--c-rule);
padding-top: 6px;
}
.footer-author {
font-size: var(--text-xs);
color: var(--c-muted);
font-weight: 400;
}
.footer-page {
font-size: var(--text-xs);
color: var(--c-muted);
font-variant-numeric: tabular-nums;
}
</style>
</head>
<body>
<div class="footer-inner">
<span class="footer-author" data-author></span>
<span class="footer-page">
<span data-page-number></span> / <span data-page-count></span>
</span>
</div>
</body>
</html>

View file

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="style.css" />
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
max-width: 100%;
}
body {
display: flex;
align-items: flex-end; /* pin content to bottom of the header zone */
padding: 0 10vw 10px;
}
.header-inner {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid var(--c-rule);
padding-bottom: 6px;
}
.header-title {
font-size: var(--text-xs);
font-weight: 500;
color: var(--c-muted);
letter-spacing: 0.04em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-dot {
width: 4px;
height: 4px;
border-radius: 50%;
background: var(--c-accent);
flex-shrink: 0;
}
</style>
</head>
<body>
<div class="header-inner">
<span class="header-title" data-title></span>
<div class="header-dot"></div>
</div>
</body>
</html>

View file

@ -0,0 +1,227 @@
/* ============================================================
CleanDoc Shared Styles
Roboto type system, A4 document layout
============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,300;0,400;0,500;0,700;1,400;1,700&family=Roboto+Mono:wght@400;500&display=swap');
/* --- Design tokens ---------------------------------------- */
:root {
/* Typefaces */
--font-body: 'Roboto', -apple-system, sans-serif;
--font-mono: 'Roboto Mono', 'Courier New', monospace;
/* A4 content column
A4 = 210mm wide. 25mm side margins each = 160mm text width.
At 96dpi: 160mm × (96/25.4) 605px.
We use 620px a comfortable line measure for Roboto 10.5pt. */
--content-width: 620px;
/* Type scale Minor Third (1.2×) anchored at 10.5pt
10.5pt @ 96dpi 14px */
--text-xs: 11px; /* captions, footer meta */
--text-sm: 12px; /* table cells, code */
--text-base: 14px; /* body — ~10.5pt on A4 */
--text-md: 16px; /* h4 / lead text */
--text-lg: 19px; /* h3 */
--text-xl: 23px; /* h2 */
--text-2xl: 28px; /* h1 in document */
--text-3xl: 42px; /* title page title */
/* Line heights — Roboto needs slightly tighter lh than serifs */
--lh-tight: 1.25;
--lh-snug: 1.45;
--lh-base: 1.65; /* body text */
--lh-loose: 1.80;
/* Colour palette */
--c-ink: #1c1c1e;
--c-mid: #48484a;
--c-muted: #8e8e93;
--c-rule: #d1d1d6;
--c-tint: #f2f2f7;
--c-accent: #0a5cf5; /* single accent — deep blue */
--c-white: #ffffff;
/* Spacing unit: 4px grid */
--sp-1: 4px;
--sp-2: 8px;
--sp-3: 12px;
--sp-4: 16px;
--sp-6: 24px;
--sp-8: 32px;
--sp-10: 40px;
--sp-12: 48px;
--sp-16: 64px;
--sp-20: 80px;
}
/* --- Reset ------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* --- Base ------------------------------------------------- */
html {
font-family: var(--font-body);
font-size: var(--text-base);
line-height: var(--lh-base);
color: var(--c-ink);
background-color: var(--c-white);
-webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility;
}
/* --- Content column --------------------------------------- */
body {
max-width: var(--content-width);
margin: 0 auto;
/* No top/bottom padding here — controlled by IATemplateHeaderHeight */
}
/* --- Headings --------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
font-family: var(--font-body);
color: var(--c-ink);
font-weight: 700;
line-height: var(--lh-tight);
margin-top: var(--sp-10);
margin-bottom: var(--sp-3);
}
/* First heading in a document should not add top margin */
.document > h1:first-child,
.document > h2:first-child,
.document > h3:first-child {
margin-top: 0;
}
h1 { font-size: var(--text-2xl); letter-spacing: -0.02em; font-weight: 300; }
h2 { font-size: var(--text-xl); font-weight: 500; border-bottom: 1.5px solid var(--c-rule); padding-bottom: var(--sp-2); }
h3 { font-size: var(--text-lg); font-weight: 500; }
h4 { font-size: var(--text-md); font-weight: 700; color: var(--c-mid); }
h5 { font-size: var(--text-base); font-weight: 700; color: var(--c-mid); }
h6 { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--c-muted); }
/* Keep heading with following paragraph */
h1 + p, h2 + p, h3 + p, h4 + p { margin-top: var(--sp-2); }
/* --- Body text -------------------------------------------- */
p { margin-bottom: var(--sp-4); }
p:last-child { margin-bottom: 0; }
strong { font-weight: 700; }
em { font-style: italic; }
a {
color: var(--c-accent);
text-decoration: underline;
text-underline-offset: 2px;
text-decoration-thickness: 1px;
}
/* --- Lists ------------------------------------------------ */
ul, ol {
padding-left: var(--sp-6);
margin-bottom: var(--sp-4);
}
li { margin-bottom: var(--sp-1); line-height: var(--lh-snug); }
li > ul, li > ol { margin-top: var(--sp-1); margin-bottom: 0; }
/* --- Blockquote ------------------------------------------- */
blockquote {
margin: var(--sp-8) 0;
padding: var(--sp-4) var(--sp-6);
border-left: 3px solid var(--c-accent);
background: var(--c-tint);
font-weight: 300;
font-size: var(--text-md);
line-height: var(--lh-snug);
color: var(--c-mid);
}
blockquote p:last-child { margin-bottom: 0; }
/* --- Code ------------------------------------------------- */
code {
font-family: var(--font-mono);
font-size: 0.875em;
font-weight: 500;
background: var(--c-tint);
padding: 0.1em 0.35em;
border-radius: 3px;
border: 1px solid var(--c-rule);
}
pre {
font-family: var(--font-mono);
font-size: var(--text-sm);
line-height: 1.6;
background: var(--c-tint);
border: 1px solid var(--c-rule);
border-radius: 4px;
padding: var(--sp-4) var(--sp-6);
margin: var(--sp-6) 0;
overflow-x: auto;
}
pre code { background: none; border: none; padding: 0; font-size: inherit; }
/* --- Tables ----------------------------------------------- */
table {
width: 100%;
border-collapse: collapse;
margin: var(--sp-6) 0;
font-size: var(--text-sm);
}
thead {
border-bottom: 2px solid var(--c-ink);
}
th {
text-align: left;
font-weight: 700;
padding: var(--sp-2) var(--sp-3);
font-size: var(--text-xs);
text-transform: uppercase;
letter-spacing: 0.06em;
color: var(--c-mid);
}
td {
padding: var(--sp-2) var(--sp-3);
border-bottom: 1px solid var(--c-rule);
vertical-align: top;
line-height: var(--lh-snug);
}
tr:last-child td { border-bottom: none; }
tbody tr:nth-child(even) td { background: var(--c-tint); }
/* --- HR --------------------------------------------------- */
hr {
border: none;
border-top: 1px solid var(--c-rule);
margin: var(--sp-10) 0;
}
/* --- Images ----------------------------------------------- */
img {
max-width: 100%;
height: auto;
display: block;
margin: var(--sp-6) auto;
}
figcaption {
text-align: center;
font-size: var(--text-xs);
color: var(--c-muted);
margin-top: var(--sp-2);
font-style: italic;
}
/* ============================================================
Night mode
============================================================ */
html.night-mode {
--c-ink: #f2f2f7;
--c-mid: #aeaeb2;
--c-muted: #636366;
--c-rule: #38383a;
--c-tint: #1c1c1e;
--c-accent: #4a9eff;
--c-white: #000000;
}

View file

@ -0,0 +1,132 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="style.css" />
<style>
/* Title page fills the full A4 page height.
IATemplateTitleUsesHeaderAndFooterHeight = false, so we own
the full viewport here — simulate 297mm tall A4 column. */
html, body {
height: 100%;
margin: 0;
padding: 0;
max-width: 100%;
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
/* Inset the content inside the A4 page.
25mm ≈ 9.4% of 210mm, so ~9.4vw each side is our side margin.
Top: ~20mm, Bottom: ~20mm */
padding: 18vh 10vw 10vh;
}
/* Top decoration strip */
.title-bar {
width: 48px;
height: 4px;
background: var(--c-accent);
margin-bottom: 12vh;
}
/* Main title block — pushed toward the upper-middle */
.title-content {
flex: 1;
display: flex;
flex-direction: column;
justify-content: flex-start;
}
.title-label {
font-size: var(--text-xs);
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.12em;
color: var(--c-muted);
margin-bottom: 20px;
}
.title-main {
font-size: clamp(28px, 5vw, var(--text-3xl));
font-weight: 300;
letter-spacing: -0.025em;
line-height: 1.1;
color: var(--c-ink);
margin-bottom: 24px;
/* Limit line length to 70% of content width for readability */
max-width: 72%;
}
.title-rule {
width: 48px;
height: 2px;
background: var(--c-rule);
margin-bottom: 24px;
}
.title-meta {
font-size: var(--text-sm);
font-weight: 400;
color: var(--c-mid);
line-height: var(--lh-loose);
}
.title-meta .author {
display: block;
font-weight: 500;
color: var(--c-ink);
}
.title-meta .date {
display: block;
color: var(--c-muted);
}
/* Bottom strip: subtle branding row */
.title-footer {
display: flex;
align-items: center;
gap: 12px;
border-top: 1px solid var(--c-rule);
padding-top: 20px;
}
.title-footer-dot {
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--c-accent);
flex-shrink: 0;
}
.title-footer-text {
font-size: var(--text-xs);
color: var(--c-muted);
letter-spacing: 0.04em;
}
</style>
</head>
<body>
<div class="title-bar"></div>
<div class="title-content">
<p class="title-label">Document</p>
<h1 class="title-main" data-title></h1>
<div class="title-rule"></div>
<div class="title-meta">
<span class="author" data-author></span>
<span class="date" data-date="d MMMM yyyy"></span>
</div>
</div>
<div class="title-footer">
<div class="title-footer-dot"></div>
<span class="title-footer-text" data-title></span>
</div>
</body>
</html>

View file

@ -0,0 +1,328 @@
# iA Writer Templates — A Practical Guide
## What is iA Writer?
iA Writer is a focused writing application for macOS, iOS, iPadOS, and Windows, developed by the Swiss studio [Information Architects (iA)](https://ia.net). It strips away the visual clutter of traditional word processors to offer a distraction-free environment centred entirely on the text itself.
Its signature features include:
- **Focus Mode** — dims everything except the sentence or paragraph you are writing
- **Syntax Highlighting** — optionally colours adjectives, nouns, verbs, and adverbs to reveal writing patterns
- **Content Blocks** — embed and transclude other files directly into a document
- **MultiMarkdown support** — a superset of standard Markdown including tables, footnotes, and metadata
- **Templates** — export any document to a beautifully typeset PDF or printed page using custom HTML/CSS templates
iA Writer saves documents as plain `.md` or `.txt` files, which means your writing is never locked into a proprietary format.
---
## Relevant Documentation
| Resource | URL |
|---|---|
| Official template guide | https://ia.net/writer/templates |
| Template GitHub repository (iainc) | https://github.com/iainc/iA-Writer-Templates |
| MultiMarkdown syntax reference | https://fletcher.github.io/MultiMarkdown-6 |
| iA Writer support | https://ia.net/writer/support |
| Apple Bundle structure reference | https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFBundles/BundleTypes/BundleTypes.html |
---
## How Templates Work
iA Writer templates are **macOS/iOS bundles** — a directory with a specific internal structure that the operating system treats as a single file. The bundle contains HTML, CSS, and a property list (`Info.plist`) that tells iA Writer which pages exist and how tall the header and footer are.
When you export a document, iA Writer renders each HTML page in a headless WebKit view and composes the result into a PDF. You have full control over typography, layout, and colour through standard HTML and CSS.
---
## Bundle Structure
```
MyTemplate.iatemplate/
└── Contents/
├── Info.plist ← Required. Declares all pages and settings.
└── Resources/
├── document.html ← Required. Lays out the document body text.
├── title.html ← Optional. Cover/title page.
├── header.html ← Optional. Repeating page header.
├── footer.html ← Optional. Repeating page footer.
└── style.css ← Your stylesheet (shared across all pages).
```
The HTML filenames can be anything you like — you declare them in `Info.plist`. The file extensions must be `.html`; in `Info.plist` you reference them **without** the extension.
---
## Info.plist Reference
`Info.plist` is an Apple XML property list. Every key-value pair is wrapped in `<key>` and its corresponding type tag. Here is a complete annotated example:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- REQUIRED -------------------------------------------------- -->
<!-- The name shown in iA Writer's template picker -->
<key>CFBundleName</key>
<string>My Template</string>
<!-- Unique reverse-DNS identifier. iA Writer uses this to associate
templates with documents. Change it if you fork a template. -->
<key>CFBundleIdentifier</key>
<string>com.yourname.mytemplate</string>
<!-- HTML file (no extension) that lays out body text pages -->
<key>IATemplateDocumentFile</key>
<string>document</string>
<!-- OPTIONAL -------------------------------------------------- -->
<!-- Cover/title page HTML file -->
<key>IATemplateTitleFile</key>
<string>title</string>
<!-- Running header HTML file + its height in CSS points (max 400) -->
<key>IATemplateHeaderFile</key>
<string>header</string>
<key>IATemplateHeaderHeight</key>
<integer>60</integer>
<!-- Running footer HTML file + its height in CSS points (max 400) -->
<key>IATemplateFooterFile</key>
<string>footer</string>
<key>IATemplateFooterHeight</key>
<integer>50</integer>
<!-- When false, title page gets zero header/footer height (full bleed) -->
<key>IATemplateTitleUsesHeaderAndFooterHeight</key>
<false/>
<!-- Human-readable metadata shown in Preferences -->
<key>IATemplateDescription</key>
<string>A clean document template.</string>
<key>IATemplateAuthor</key>
<string>Your Name</string>
<key>IATemplateAuthorURL</key>
<string>https://yourwebsite.com</string>
<!-- Set to false to disable Smart Tables processing -->
<key>IATemplateSuportsSmartTables</key>
<true/>
<!-- Set to false to disable TeX math → MathML conversion -->
<key>IATemplateSupportsMath</key>
<true/>
</dict>
</plist>
```
> **Important:** The `CFBundleIdentifier` must be unique. If two installed templates share the same identifier, iA Writer will associate documents with whichever was installed last. Always change the identifier when forking a template.
---
## Content Injection — `data-*` Attributes
iA Writer populates your HTML pages by setting `innerHTML` on elements that carry specific `data` attributes. It dispatches an `ia-writer-change` event to each element after updating it.
### Available on all pages
| Attribute | Content |
|---|---|
| `data-title` | Document title (taken from the filename) |
| `data-author` | Author name set in iA Writer Preferences |
| `data-date` | Current date. Accepts a format string: `data-date="d MMMM yyyy"` |
### Document page only
| Attribute | Content |
|---|---|
| `data-document` | The full document body rendered as HTML |
### Header, footer, and title page
| Attribute | Content |
|---|---|
| `data-page-number` | Current page number (not available on title page) |
| `data-page-count` | Total page count |
### Usage in HTML
```html
<!-- Populate an element with the document title -->
<h1 data-title></h1>
<!-- Inject the full document body -->
<div data-document></div>
<!-- Page number out of total -->
<span data-page-number></span> / <span data-page-count></span>
<!-- Date with a custom format -->
<span data-date="MMMM yyyy"></span>
```
---
## Margin Model
This is the most important thing to understand before writing CSS, and the most common source of confusion.
**Left and right margins** are controlled purely by CSS — typically via `max-width` on the `body` or a container `div`, combined with `margin: 0 auto`.
**Top and bottom margins** on body pages are controlled by `IATemplateHeaderHeight` and `IATemplateFooterHeight` in `Info.plist`. CSS top/bottom padding on the `body` element of `document.html` does **not** create print margins in the same way — the header and footer zones sit above and below the document body zone, and their heights are what determines white space at the top and bottom of each page.
### A4 margin calculation
| Margin | Value | CSS pixels (96 dpi) |
|---|---|---|
| Top (= header height) | 25 mm | ~94 px |
| Bottom (= footer height) | 20 mm | ~75 px |
| Left/Right | 25 mm each | max-width ≈ 605640 px |
A common working formula for A4 with 25mm margins:
```
A4 width = 210mm
Side margins = 25mm × 2 = 50mm
Text column = 160mm = 160 × (96 ÷ 25.4) ≈ 605px
```
```xml
<key>IATemplateHeaderHeight</key>
<integer>94</integer>
<key>IATemplateFooterHeight</key>
<integer>75</integer>
```
```css
body {
max-width: 620px;
margin: 0 auto;
}
```
---
## The Five HTML Pages
### `document.html` (required)
This page renders the Markdown body text. Keep it minimal — just import your stylesheet and place a single `data-document` element.
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div data-document></div>
</body>
</html>
```
### `title.html` (optional)
The cover page, only rendered on export. Because `IATemplateTitleUsesHeaderAndFooterHeight` can be set to `false`, this page can go full-bleed. Use `min-height: 100vh` and flexbox to fill the page.
```html
<body style="display:flex; flex-direction:column; min-height:100vh; padding:15vh 10vw;">
<h1 data-title></h1>
<p data-author></p>
<p data-date="d MMMM yyyy"></p>
</body>
```
### `header.html` and `footer.html` (optional)
These repeat on every body page. Their viewport height equals the value you set in `Info.plist`. Use flexbox to align content to the inner edge (the edge closest to the body text):
- **Header:** `align-items: flex-end` to pin content to the bottom of the header zone
- **Footer:** `align-items: flex-start` to pin content to the top of the footer zone
```html
<!-- footer.html -->
<body style="display:flex; align-items:flex-start; padding:8px 0 0;">
<span data-page-number></span> / <span data-page-count></span>
</body>
```
---
## Night Mode & iOS Support
iA Writer adds CSS classes to the `<html>` element to signal the current environment. Use these to adapt your template:
```css
/* Dark mode */
html.night-mode {
background: #1c1c1e;
color: #f2f2f7;
}
/* Platform targeting */
html.mac { /* macOS-specific overrides */ }
html.ios { /* iOS/iPadOS overrides */ }
```
iOS also supports Dynamic Type. iA Writer adds a content-size class to `<html>`:
```css
html.content-size-s { font-size: 14px; }
html.content-size-l { font-size: 17px; } /* default */
html.content-size-xl { font-size: 20px; }
```
---
## Installing a Template
### macOS
Double-click the `.iatemplate` bundle in Finder, or drag it onto the iA Writer icon in the Dock. You can also go to **Preferences → Templates → +**.
To inspect or edit an installed template: right-click it in Preferences and choose **Show in Finder**, then right-click the bundle and choose **Show Package Contents**.
### iOS / iPadOS
Send the `.iatemplate` file (or a `.zip` containing one template) via AirDrop, or use **Open in iA Writer** from Files, Mail, or Safari.
### Windows
Go to **File → Install Template** and select the `.iatemplate.zip` file.
---
## Development Workflow
1. Install the template in iA Writer once via Preferences.
2. Right-click it in Preferences → **Show in Finder** to locate the installed copy.
3. Edit the HTML/CSS files directly inside the installed bundle.
4. Press **⇧⌘R** in iA Writer's Preview pane to force-reload the template.
5. Enable Web Inspector for deeper debugging:
```bash
defaults write pro.writer.mac WebKitDeveloperExtras -bool true
```
Then right-click inside the Preview pane and choose **Inspect Element**.
---
## About ExampleTemplate_CleanDoc
`ExampleTemplate_CleanDoc` is the template included alongside this README. It demonstrates all five template pages with a Roboto type system, calibrated A4 margins, a structured title page, running header/footer with page numbers, and full night mode support.
| File | Purpose |
|---|---|
| `Info.plist` | Declares all five pages, sets header (60px) and footer (50px) heights |
| `style.css` | Shared design tokens, Roboto type scale, component styles, night mode |
| `document.html` | Body text page |
| `title.html` | Full-bleed cover page with accent bar, title, author, date |
| `header.html` | Running title + accent dot |
| `footer.html` | Author name (left) + page N / total (right) |