Skip to content

Add four new themes and the theme-base changes they need - #168

Merged
spring-raining merged 20 commits into
mainfrom
feat/add-new-themes-1
Nov 14, 2026
Merged

spring-raining merged 20 commits into
mainfrom
feat/add-new-themes-1

Conversation

@spring-raining

Copy link
Copy Markdown
Member

Adds four new official themes, along with the @vivliostyle/theme-base changes that their layouts needed and a script to browse the built example PDFs.

  • New themes: Each one comes with a default template.
    • @vivliostyle/theme-centered-heading-line-graph: a two-column theme for English textbooks with centered numbered headings, tables with colored headers and line graphs. The configs set vfm.disableFormatHtml so that the space after an empty reference survives.
    • @vivliostyle/theme-mono-hanging-number-sidenote: a single-column theme for English university textbooks, set in monospace with hanging section numbers and numbered sidenotes in the outer margin.
    • @vivliostyle/theme-wide-margin-speaker-indent: a single-column theme with wide margins for technical doujinshi, with hanging indents under speaker names, pull quotes between thin rules and code blocks among the remarks.
    • @vivliostyle/theme-vertical-numbered-heading-graph: a single-column vertical theme for academic nonfiction, with section headings numbered in kanji numerals, horizontal graphs as page floats at the bottom of the page and endnotes.
  • theme-base features (minor):
    • --vs--figure-gap spaces the items of a figure with gap instead of the margin-block of figcaption.
    • --vs-section--label and the number-only --vs-section--call-counter-content and --vs-section--marker-counter-content split the section reference into a label and a number. References now read Section 1.2 (1.2節 in Japanese) instead of §1.2.
    • --vs--li-break-inside, --vs--table-row-break-inside and --vs-section--h1-break-inside to --vs-section--h6-break-inside control page breaks inside list items, table rows and sections.
  • theme-base fixes (patch):
    • The figure, table and listing numbering, the section break-before/break-after and the table of contents rules have a lower specificity, so that a theme can override them with a class or attribute selector.
    • The endnote call stays at the height of other superscripts instead of rising to the previous line.
  • pnpm example:list-pdf writes packages/@vivliostyle/index.html, which lists the built example PDFs with previews of their first pages. The pdf.js rendering moves to scripts/pdf-render.ts, shared with capture-pdf.ts.

The release notes are in .changeset/.

Assisted-by: Claude Code:claude-opus-5-5

How the AI was used
  • The human author decided the concept of each theme, and the changes to theme-base that the themes needed, and reviewed the layouts in the built PDFs.
  • The AI drafted the theme CSS, the templates, the theme-base changes, the example:list-pdf script, the changesets and this description.
  • The human author reviewed the diff and the PDFs of the examples.

🤖 Generated with Claude Code

https://claude.ai/code/session_012bEdWFtNhpQm8N2xisureo

`pnpm example:list-pdf` writes `packages/@vivliostyle/index.html`, which
lists the PDFs left in each theme package with previews of their first
pages. The pdf.js rendering moves from `capture-pdf.ts` to
`pdf-render.ts` so that both scripts share it.

Assisted-by: Claude Code:claude-opus-5-5
…n margin

The `margin-block` of `figcaption` also added space on the outer side of
the caption, on top of the figure's own margin, and left no space
between images in the same figure. `--vs--figure-gap` sets the space
between the items of the flex container instead.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWCYMcfddVwpY3dkusb
…listing numbering

With `:is()`, the selectors such as `figure:is(.fig, :has(> :is(img,
picture))) figcaption::before` took the specificity of the class, so a
theme rule like `.chart figcaption::before { content: none; }` lost to
them. `:where()` leaves only the `figure` type selector to count.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWCYMcfddVwpY3dkusb
`--vs-section--call-counter-content` and
`--vs-section--marker-counter-content` hold only the number, so a theme
can change the numbering, such as prefixing the chapter number, without
rewriting the label. `--vs-section--label` replaces the `§` sign with
`Section `, and with `節` placed after the number in Japanese, as
section references read in each language.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWCYMcfddVwpY3dkusb
A two-column theme for English textbooks that typesets data-heavy pages
with centered numbered headings, tables with colored headers, and line
graphs. The default template is a chapter of a microeconomics textbook.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWBrzzgSRLKs9Bon8rr
…es without ` `

The HTML formatting of VFM treats an empty element such as
`<a data-ref="fig"></a>` as if it were not there, and drops the
whitespace right after it when whitespace also precedes it. A reference
then runs into the following word, as in `Figure 7.1plots`, which the
template worked around with `&nbsp;`. Set `vfm.disableFormatHtml` in
the configs so plain spaces survive, and drop the workaround.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWFJmP9qLYtufoN39U7
…rows and sections

Themes set `break-inside: avoid` directly on list items, table rows and
sections to keep an item, a row or a short section on one page.
`--vs--li-break-inside`, `--vs--table-row-break-inside` and
`--vs-section--h1-break-inside` to `--vs-section--h6-break-inside` let
them do so through variables. The table row and section rules are
matched with `:where()`, since `section:has(> h2:first-child)` outweighs
a theme's `section.level2` and would reset its value to `auto` while the
variable is unset. A table row only splits once
`--vs--table-break-inside` is `auto`, as the table avoids breaks by
default.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWCYMcfddVwpY3dkusb
… of contents

`section:has(> h2:first-child)` outweighs a selector such as
`section.level2`, so `break-before` and `break-after` written directly
by a theme were reset to `auto` while the variables were unset. They now
share the `:where()` rule of `break-inside`. The table of contents rules
matched `:is(#toc, [role='doc-toc'])`, which counts as an ID and
outweighed any selector a theme could write without one. `[id='toc']`
matches the same element with the specificity of `[role='doc-toc']`.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWCYMcfddVwpY3dkusb
A single-column theme for English university textbooks, set entirely in
monospace with hanging section numbers and numbered sidenotes in a band
along the outer margin. The default template is a chapter of a
programming textbook on parsing.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWFJmP9qLYtufoN39U7
…ripts

The `vertical-align` of `.footnote-ref > sup` fell back to an empty
value while `--vs--sup-vertical-align` was unset, so the browser's
`vertical-align: super` came back on top of the `inset-block-start`
shift of `sup`, and the call rose as high as the previous line. It now
falls back to `baseline`.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWCYFAHRX9demS8AtEr
A single-column theme with wide margins for technical doujinshi. It sets
interview pages with hanging indents under speaker names, and places pull
quotes between thin rules and code blocks among the remarks. The default
template is a Japanese book of conversations looking back on three
incidents at a company.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWF5PDqCaupfhhF8So9
A single-column vertical theme for academic nonfiction, with section
headings numbered in kanji numerals and horizontal graphs placed at the
bottom of the page as page floats. Endnotes are supported. The default
template is a chapter of a Japanese book on the modernization of weights
and measures.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWF3piL8nQH9WSzkZ59
…al link footnotes

The theorem label rules carried the conditions that choose its element,
`.theorem > p:only-child::before` and
`.theorem:not(:has(> p:only-child))::before`, at (0,2,2), so
`.theorem::before` in a theme lost on every multi-paragraph theorem. The
external link rules carried `:not(.footnote)` at (0,2,1), so a later rule
on `a[href^='http']` lost in print. Both conditions now sit in
`:where()`, which leaves where the label goes and which links are
footnoted unchanged.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWD4BEh6qT2zmSdDZhg
…ism module

The prism module set `white-space`, `word-break`, `text-align`,
`overflow`, the background, the padding and the text color on
`pre[class*='language-']` and `code`. VFM gives every code block a
`language-*` class, so with the module loaded the `--vs--pre-*` and
`--vs--monospace-*` variables and a theme's `pre {}` had no effect on
code blocks, and the code inside them no longer inherited from `pre`.

The module now leaves the layout to the basic stylesheet and sets only
what Prism adds, with the specificity of `pre` and `code`. The
`--vs--pre-*` color, background and radius variables take precedence
over their Prism counterparts. `--vs-prism--block-code-padding` is a
`padding` shorthand and cannot fall back per axis, so its default takes
`--vs--pre-padding-block` and `--vs--pre-padding-inline` instead.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWD4BEh6qT2zmSdDZhg
@spring-raining
spring-raining marked this pull request as ready for review November 10, 2026 16:12
@MurakamiShinyu

Copy link
Copy Markdown
Member

だいたいよさそうですが、以下少し気になったところです:

@vivliostyle/theme-centered-heading-line-graph

  • 「Summary」「Key Terms」などの段組内での箇条書きで、最初の段だけ先頭行の上にマージンが付き、2段目と先頭行の位置が揃っていない。箇条書きの ul・ol のmargin-block-startが問題のようです。
Screenshot 2026-11-11 14 36 32

@vivliostyle/theme-vertical-numbered-heading-graph

  • ページの柱とノンブルの左端の位置が縦書きページ本文の最終行の左端の位置よりも左になってる。theme-bunko ではそうならないように柱のマージンボックスの小口側のマージンを調整しているので同様にするとよいと思います。
  • 注参照の番号が行頭になってしまう問題がある。「不可欠であると考えた2。」の「2。」が行頭に配置されてしまう。注参照の番号の前で行分割禁止にするのにWORD JOINER U+2060 を使うとよいかもしれない(CSSの[wrap-before](https://drafts.csswg.org/css-text-4/#propdef-wrap-before) が使えるようになるまで)。
Screenshot 2026-11-11 19 02 08

@vivliostyle/theme-wide-margin-speaker-indent

  • 目次の項目に番号が振られていない。本文の見出しでは「1 鳴らなかったアラート」「2 二重に走った夜間ジョブ」のように番号があるので、同じ番号が目次の項目にはないのが不自然。

…ble of contents

The README says that chapter entries in the generated table of contents
get chapter numbers, and the h1 marker ends with a full-width space so
that the table of contents can copy it, but the rule that copies it was
missing. The entries now take the text of the h1 `::before` with
`target-text(attr(href), before)`. The introduction and the colophon
also have a chapter counter value, so `target-counter()` would number
them too, while their marker is not displayed and gives an empty string.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWD4BEh6qT2zmSdDZhg
…and the folio with the text

The running head and the folio started at the edge of the page area,
while the glyphs of the outermost lines sit half the leading inside
their line, and the 16 lines leave 1.1mm empty on the left of the text
area. On left pages the boxes stuck out 2.3mm to the left of the last
line, and on right pages the folio stuck out 1.1mm to the right of the
first line. The outer margin boxes now have an inside margin, as in
`theme-bunko`, so that their edges line up with the glyphs.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWDkmWH5PeLeaHr7zgu
…ting a line

A line could break before a note call, so that a line started with the
note number, as in "2。". The call now begins with a WORD JOINER
(U+2060) in `::before`, which prevents the break until `wrap-before`
is supported.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWDkmWH5PeLeaHr7zgu
…ets from the type size and the page size

The inside margins of the outer margin boxes were measured values for the
default type size, leading and page size, so the running head and the
folio no longer lined up with the text when a user changed any of them.
They are now computed from `1rem`, `1rlh`, `100pvw` and the page margin
variables: half the leading on both sides, plus on the left the part of
the text area that whole lines leave over. Vivliostyle ignores `mod()`
in this context, so the remainder is computed with its `floor()`.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWDkmWH5PeLeaHr7zgu
…panning heading

The first block below a section heading kept its top margin in the
first column only, since the other columns start at a column break, so
the lists of the closing sections began lower in the first column than
in the second. The block that follows a heading from h1 to h6 now has
no top margin, nor has a subsection heading that follows at once, whose
margin would otherwise pass up through its section.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWDsHB9mxbBoXg1wWYE
…ction with a subsection

The example had no subsection heading right after a section heading,
the case in which the margin of the subsection heading lowered only the
first column. The price controls section now starts with "Price
Ceilings" and continues with "Price Floors", and its opening paragraph
is split between the two.

Assisted-by: Claude Code:claude-opus-5-5
Claude-Session: https://claude.ai/code/session_012bEdWDsHB9mxbBoXg1wWYE
@spring-raining

Copy link
Copy Markdown
Member Author

@MurakamiShinyu すべて修正しました!

「Summary」「Key Terms」などの段組内での箇条書きで、最初の段だけ先頭行の上にマージンが付き、2段目と先頭行の位置が揃っていない

こちらは他の複数段組みのレイアウトでも起こる問題のため本来であればbase themeで修正したい問題ですが、そのために revert-rule の挙動についてVivliostyle.js側で改善したい箇所が見つかりました。この問題は後ほどissueを作成します。

@MurakamiShinyu MurakamiShinyu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@spring-raining
spring-raining merged commit db35ef8 into main Nov 14, 2026
6 checks passed
@spring-raining
spring-raining deleted the feat/add-new-themes-1 branch November 14, 2026 09:54
@github-actions github-actions Bot mentioned this pull request Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants