shiroa

Typst Support - Package API

The @preview/shiroa:0.4.0@preview/shiroa:0.4.0 package is the Typst-side interface shared by a Shiroa book, its page template, and its theme. It describes the book, exposes the current rendering target, and provides helpers for links, HTML, media, and theme implementation.

The public entry point is packages/shiroa/lib.typpackages/shiroa/lib.typ. Names that are useful only while implementing a theme are marked as advanced. Implementation details from files ending in -internal.typ-internal.typ are not part of this API.

Importing the package

Import only the names a file uses:

#import "@preview/shiroa:0.4.0": (
book,
book-meta,
chapter,
get-page-width,
is-html-target,
)
#import "@preview/shiroa:0.4.0": (
book,
book-meta,
chapter,
get-page-width,
is-html-target,
)

For a book.typbook.typ, importing all book-description helpers is also convenient:

#import "@preview/shiroa:0.4.0": *
#show: book
#book-meta(
title: "My Book",
summary: [
#prefix-chapter("introduction.typ")[Introduction]
= Guide
- #chapter("guide/start.typ")[Getting Started]
],
)
#import "@preview/shiroa:0.4.0": *
#show: book
#book-meta(
title: "My Book",
summary: [
#prefix-chapter("introduction.typ")[Introduction]
= Guide
- #chapter("guide/start.typ")[Getting Started]
],
)

The entry point also exports three modules intended for namespace imports:

  • mediamedia: Portable multimedia elements. See the HTML embedding chapter.
  • html-supporthtml-support: HTML assets, slots, and low-level bindings used by themes.
  • templatestemplates: Helpers for page templates and custom themes.

link-supportlink-support and text-supporttext-support expose the modules behind cross-linkcross-link and plain-textplain-text. Most callers should import those two functions directly.