Typst Support - Rendering Targets and Inputs
Shiroa passes compilation state through sys.inputssys.inputs. Use the exported values and predicates instead of reading the inputs repeatedly in each template.
#import "@preview/shiroa:0.4.0": x-target#assert(type(x-target) == str)
#import "@preview/shiroa:0.4.0": x-target#assert(type(x-target) == str)
The logical output target. Common values are:
pdfpdf: A paged PDF or editor preview.web-lightweb-light,web-ayuweb-ayu, and otherweb-*web-*variants: A paged document rendered for the browser.htmlhtml: A native Typst HTML page.html-wrapperhtml-wrapper: An HTML page that loads a separately rendered paged document.
targettarget is a deprecated alias. New templates should use x-targetx-target.
is-html-target()is-html-target()accepts bothhtmlhtmlandhtml-wrapperhtml-wrapper.is-html-target(exclude-wrapper: true)is-html-target(exclude-wrapper: true)accepts native HTML but excludes the dynamic paged wrapper.is-web-target()is-web-target()acceptswebwebandweb-*web-*variants.is-pdf-target()is-pdf-target()acceptspdfpdfandpdf-*pdf-*variants.
#import "@preview/shiroa:0.4.0": ( is-html-target, is-pdf-target, is-web-target,)#if is-html-target(exclude-wrapper: true) [Native HTML]#if is-web-target() [Paged web content]#if is-pdf-target() [PDF or editor preview]
#import "@preview/shiroa:0.4.0": ( is-html-target, is-pdf-target, is-web-target,)#if is-html-target(exclude-wrapper: true) [Native HTML]#if is-web-target() [Paged web content]#if is-pdf-target() [PDF or editor preview]
#import "@preview/shiroa:0.4.0": get-page-width, page-width#assert(get-page-width() == page-width)
#import "@preview/shiroa:0.4.0": get-page-width, page-width#assert(get-page-width() == page-width)
The width selected by Shiroa for the current responsive layout. The function form is preferred in page templates.
#import "@preview/shiroa:0.4.0": get-page-width, is-web-target#set page( width: get-page-width(), height: auto,) if is-web-target()
#import "@preview/shiroa:0.4.0": get-page-width, is-web-target#set page( width: get-page-width(), height: auto,) if is-web-target()
#import "@preview/shiroa:0.4.0": x-url-base#assert(x-url-base.starts-with("/") and x-url-base.ends-with("/"))
#import "@preview/shiroa:0.4.0": x-url-base#assert(x-url-base.starts-with("/") and x-url-base.ends-with("/"))
The normalized deployment prefix. It always starts and ends with //. Prefix site-local links and assets with it when the book can be hosted below a path such as /project//project/.
#import "@preview/shiroa:0.4.0": x-current#assert(x-current == none or type(x-current) == str)
#import "@preview/shiroa:0.4.0": x-current#assert(x-current == none or type(x-current) == str)
The current source path, or nonenone outside a Shiroa page compilation. Themes use it to highlight the active chapter and expand {path}{path} in edit links.
#import "@preview/shiroa:0.4.0": shiroa-sys-target#assert(type(shiroa-sys-target) == function)
#import "@preview/shiroa:0.4.0": shiroa-sys-target#assert(type(shiroa-sys-target) == function)
Returns "html""html" when Typst is compiling with the native HTML target and "paged""paged" otherwise. This is different from x-targetx-target: it answers which Typst engine target is active, while x-targetx-target describes Shiroa’s logical role for that compilation.
#import "@preview/shiroa:0.4.0": book-sys#assert("target" in book-sys)#assert("page-width" in book-sys)#assert("sys-is-html-target" in book-sys)
#import "@preview/shiroa:0.4.0": book-sys#assert("target" in book-sys)#assert("page-width" in book-sys)#assert("sys-is-html-target" in book-sys)
A snapshot containing the target values and predicates above. Prefer the individual functions in new templates; the dictionary is useful when passing all target state through another API.