Skip to content

Commit 39b5ea5

Browse files
build: bump shiroa packages to v0.3.1 (Myriad-Dreamin#223)
1 parent e883695 commit 39b5ea5

32 files changed

+82
-57
lines changed

cli/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async fn init(args: InitArgs) -> Result<()> {
118118
dir.join("book.typ"),
119119
format!(
120120
r##"
121-
#import "@preview/shiroa:0.3.0": *
121+
#import "@preview/shiroa:0.3.1": *
122122
123123
#show: book
124124
@@ -153,7 +153,7 @@ Sample page
153153
write_file(
154154
dir.join("ebook.typ"),
155155
format!(
156-
r##"#import "@preview/shiroa:0.3.0": *
156+
r##"#import "@preview/shiroa:0.3.1": *
157157
158158
#import "{ebook_template}"
159159

cli/src/project.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ impl Project {
194194
}
195195

196196
let InternalPackageMeta::Package { version } = self.query_meta("<shiroa-internal-package-meta>", query)?
197-
.context("No package meta. are you using old book package?, please import @preview/shiroa:0.3.0; or do you forget the show rule `#show: book`?")?;
197+
.context("No package meta. are you using old book package?, please import @preview/shiroa:0.3.1; or do you forget the show rule `#show: book`?")?;
198198

199-
if version != "0.3.0" {
199+
if version != "0.3.1" {
200200
return Err(error_once!(
201-
"outdated book package, please import @preview/shiroa:0.3.0", importing_version: version,
201+
"outdated book package, please import @preview/shiroa:0.3.1", importing_version: version,
202202
));
203203
}
204204
}

cli/src/render/typst.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use reflexo_typst::{
2121
config::CompileOpts,
2222
escape::{escape_str, AttributeEscapes},
2323
path::{unix_slash, PathClean},
24-
static_html,
24+
print_diagnostics, static_html,
2525
system::SystemWorldComputeGraph,
2626
vector::{
2727
ir::{LayoutRegionNode, Module, Page, PageMetadata},
@@ -30,9 +30,9 @@ use reflexo_typst::{
3030
},
3131
world::{diag::print_diagnostics_to, EntryOpts},
3232
CompilationTask, CompileSnapshot, DiagnosticFormat, DiagnosticHandler, DynSvgModuleExport,
33-
EntryReader, ExportDynSvgModuleTask, FlagTask, ImmutStr, LazyHash, SystemCompilerFeat, TakeAs,
34-
TaskInputs, TypstAbs, TypstDict, TypstDocument, TypstHtmlDocument, TypstPagedDocument,
35-
TypstSystemWorld,
33+
EntryReader, ExportDynSvgModuleTask, FlagTask, ImmutStr, LazyHash, SourceWorld,
34+
SystemCompilerFeat, TakeAs, TaskInputs, TypstAbs, TypstDict, TypstDocument, TypstHtmlDocument,
35+
TypstPagedDocument, TypstSystemWorld,
3636
};
3737
use reflexo_typst::{CompileReport, TypstSystemUniverse};
3838
use reflexo_vec2svg::{
@@ -229,13 +229,14 @@ impl TypstRenderer {
229229

230230
// todo: review me.
231231
if !task.ctx.static_html {
232-
THEME_LIST
232+
let res = THEME_LIST
233233
.into_par_iter()
234234
.map(|theme| {
235235
let mut task = self.spawn_with_theme(path, theme)?;
236236
task.compile_paged_page_with(settings.clone())
237237
})
238-
.collect::<Result<()>>()?;
238+
.collect::<Result<()>>();
239+
print_diag_or_error(task.world(), res)?;
239240
}
240241

241242
Ok((task, doc))
@@ -1004,6 +1005,21 @@ fn no_foreign_obj_diag(diag: &&typst::diag::SourceDiagnostic) -> bool {
10041005
!diag.message.contains("image contains foreign object")
10051006
}
10061007

1008+
fn print_diag_or_error<T>(world: &impl SourceWorld, result: Result<T>) -> Result<T> {
1009+
match result {
1010+
Ok(v) => Ok(v),
1011+
Err(err) => {
1012+
if let Some(diagnostics) = err.diagnostics() {
1013+
print_diagnostics(world, diagnostics.iter(), DiagnosticFormat::Human)
1014+
.context_ut("print diagnostics")?;
1015+
bail!("compile failed");
1016+
}
1017+
1018+
Err(err)
1019+
}
1020+
}
1021+
}
1022+
10071023
pub struct HtmlRenderContext<'a> {
10081024
pub search: &'a SearchCtx<'a>,
10091025
pub dest_dir: &'a Path,

contrib/typst/gh-ebook.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "@preview/shiroa:0.3.0": *
1+
#import "@preview/shiroa:0.3.1": *
22
#import "/contrib/typst/gh-pages.typ": part-style, project
33

44
#let _page-project = project

contrib/typst/gh-pages.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This is important for shiroa to produce a responsive layout
22
// and multiple targets.
3-
#import "@preview/shiroa:0.3.0": (
3+
#import "@preview/shiroa:0.3.1": (
44
get-page-width, is-html-target, is-pdf-target, is-web-target, plain-text, shiroa-sys-target, templates,
55
)
66
#import templates: *

github-pages/docs/book.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#import "@preview/shiroa:0.3.0": *
2+
#import "@preview/shiroa:0.3.1": *
33

44
#show: book
55

github-pages/docs/cli/init.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ your `book.typ` should at least provide a `book-meta`.
4444

4545
#sample-file("/tests/minimal/book.typ")
4646

47-
Your `template.typ` must import and respect the `get-page-width` and `target` variable from `@preview/shiroa:0.3.0` The two variables will be used by the tool for rendering responsive layout and multiple targets.
47+
Your `template.typ` must import and respect the `get-page-width` and `target` variable from `@preview/shiroa:0.3.1` The two variables will be used by the tool for rendering responsive layout and multiple targets.
4848

4949
#sample-file("/tests/minimal/template.typ")
5050

github-pages/docs/format/theme.typ

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ A target can be suffixed with a theme name to support specialized rendering for
3333

3434
== Respecting `x-target` in your template
3535

36-
To apply set rules for different targets, your `template.typ` can import and respect the `x-target` variable from `@preview/shiroa:0.3.0`. For example, to remove margins for web target, you can do:
36+
To apply set rules for different targets, your `template.typ` can import and respect the `x-target` variable from `@preview/shiroa:0.3.1`. For example, to remove margins for web target, you can do:
3737

3838
```typ
39-
#import "@preview/shiroa:0.3.0": x-target
39+
#import "@preview/shiroa:0.3.1": x-target
4040
4141
#let project(body) = {
4242
@@ -66,7 +66,7 @@ There are samples to create components that utilize metadata from `book.typ`:
6666
Shiroa will pre-render multiple layouts by setting `sys.page-width` and `sys.x-target` to different values. A template must use `page-width` to adjust the page width to avoid the content being cut off.
6767

6868
```typ
69-
#import "@preview/shiroa:0.3.0": page-width, x-target
69+
#import "@preview/shiroa:0.3.1": page-width, x-target
7070
7171
#let project(body) = {
7272
// set web/pdf page properties
@@ -80,7 +80,7 @@ Shiroa will pre-render multiple layouts by setting `sys.page-width` and `sys.x-t
8080
We know shiroa will render a page with `sys.x-target` set to `html-wrapper` and `web` targets, so template must be aware of that. The html file (rendered with `html-wrapper` target) must contain a trampoline to load the svg file (rendered with `web` target). You can either create you owned trampoline or use the `paged-load-trampoline` function provided by shiroa:
8181

8282
```typ
83-
#import "@preview/shiroa:0.3.0": paged-load-trampoline, x-target
83+
#import "@preview/shiroa:0.3.1": paged-load-trampoline, x-target
8484
#let html-template(trampoline) = html.html(
8585
html.head(html.title("Page Title")),
8686
html.body(trampoline),

github-pages/docs/guide/get-started.typ

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import "/github-pages/docs/book.typ": book-page
2-
#import "@preview/shiroa:0.3.0": shiroa-sys-target
2+
#import "@preview/shiroa:0.3.1": shiroa-sys-target
33

44
#show: book-page.with(title: "Get Started")
55

@@ -46,7 +46,7 @@ Before a chapter can be viewed, it must be added to this list.
4646
Here's a basic summary file with a few chapters:
4747

4848
```typ
49-
#import "@preview/shiroa:0.3.0": *
49+
#import "@preview/shiroa:0.3.1": *
5050
#show: book
5151
5252
#book-meta( // put metadata of your book like book.toml of mdbook

github-pages/docs/pdf.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import "@preview/shiroa:0.3.0": *
1+
#import "@preview/shiroa:0.3.1": *
22

33
#import "/contrib/typst/gh-ebook.typ"
44
#let ebook = gh-ebook

0 commit comments

Comments
 (0)