-
Notifications
You must be signed in to change notification settings - Fork 3
Adds mechanism to conditionally check EPUB #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d3339fa to
5e172f8
Compare
"epub" from target()
breezykermo
added a commit
that referenced
this pull request
Jan 25, 2026
* Adds mechanism to conditionally check EPUB (#68) * Updates git submodules to latest * Updates git submodules to latest * Returns "epub" in target() during EPUB compilation * Updates git submodules to latest * Extracts XHTML content from EPUB archives for testing * Saves EPUB XHTML content to reference files during test updates * Verifies EPUB XHTML content against reference files during tests * Tests target() function behavior in imported modules * Adds XHTML reference files for all EPUB tests * Updates EPUB module reference output to desired behavior * Injects target() override into all Typst files during EPUB compilation * Tests target() override in Typst Universe packages * Uses sys.inputs for EPUB target detection instead of target() override * Documents sys.inputs.rheo-target pattern for EPUB detection * Injects target() polyfill using sys.inputs for EPUB compilation * Documents sys.inputs.rheo-target for library developers * Updates git submodules to latest * Fixes lints * Updates git submodules to latest * Renders <br/> tags as self-closing in EPUB (#70) * Renders <br/> tags in EPUB * Fixes lints * Corrects doc links in README (#76) * Defaults to reasonable font (#77) * Defaults to reasonable font This is necessary for MacOS. * Use Times New Roman as a default font * Release 0.1.1
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Rheo introduces a third supported target to Typst, EPUB. The target function in Typst allows the user to conditionally render based on the output, and we want that ability in Rheo for EPUB.
An important consideration is that one of Rheo's design goals is not to introduce new syntax, as we want a user to be able to take a file out of Typst and, in principle, compile it with the Typst toolchain instead. (We also certainly want all valid Typst files to be valid Rheo files.) EPUB compilation is, however, a feature that only exists in Rheo.
This PR implements EPUB target detection using Typst's inputs mechanism. Rheo sets
sys.inputs.rheo-targetto"epub","html", or"pdf"during compilation viaLibraryBuilder::with_inputs(). For user convenience, rheo also injects atarget()polyfill during EPUB compilation:This allows users to write natural Typst code like
if target() == "epub"without any special imports or syntax in code that will be compiled by rheo.For library developers: The
target()polyfill is syntactic sugar that shadows the local function name. Packages that callstd.target()(which is common practice to access the "real" target) will bypass the polyfill and see"html"(the underlying compilation target for EPUB). Library authors who want to support rheo's EPUB detection should checksys.inputs.rheo-targetdirectly:This pattern gracefully degrades in vanilla Typst, where
sys.inputsexists but won't contain therheo-targetkey.