https://github.com/sillyfreak/typst-bullseye
Hit the target (HTML or paged/PDF) when styling your Typst document
https://github.com/sillyfreak/typst-bullseye
typst typst-package
Last synced: 8 months ago
JSON representation
Hit the target (HTML or paged/PDF) when styling your Typst document
- Host: GitHub
- URL: https://github.com/sillyfreak/typst-bullseye
- Owner: SillyFreak
- License: mit
- Created: 2025-07-26T08:20:29.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-26T22:34:25.000Z (11 months ago)
- Last Synced: 2025-07-27T02:12:02.919Z (11 months ago)
- Topics: typst, typst-package
- Language: Typst
- Homepage:
- Size: 251 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Bullseye
This library helps you write target-dependent Typst code, particularly target-dependent content and show rules.
This package consists of two parts:
- At the foundation, it contains a wrapper around the currently unstable Typst features for target detection and HTML output.
- Built on top of that are a few helpful functions that allow package and document authors to easily write content and show rules that behave differently based on the target.
Bullseye makes sure that your code compiles even when HTML support is not enabled (e.g. in the web app or when previewing using Tinymist) _as long as_ no HTML specific content ends up in the rendered document, and automatically switches to Typst's HTML support when it is enabled.
## Getting Started
To add this package to your project, use this:
```typ
#import "@preview/bullseye:0.1.0": *
// apply styling only for non-HTML output
#show: show-target(paged: doc => {
set page(height: auto)
import "@preview/codly:1.3.0"
show: codly.codly-init
doc
})
// apply image styling only for html output
#show image: show-target(html: img => {
html.elem("img", attrs: ("src": img.source, "alt": img.alt))
})
// insert content only for HTML output
#context on-target(html: {
html.elem("a", attrs: (href: "#"))[(back to top)]
})
```
## Usage
See the [manual](docs/manual.pdf) for details.