diff --git a/.gitmodules b/.gitmodules index 2ffc91f..ae89579 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,5 +1,5 @@ [submodule "assets/artifacts"] path = assets/artifacts url = https://github.com/Myriad-Dreamin/typst/ - branch = assets-book-v0.1.3-2 + branch = assets-book-v0.1.4 shallow = true \ No newline at end of file diff --git a/CHANGELOG/CHANGELOG-0.1.md b/CHANGELOG/CHANGELOG-0.1.md index 738d537..72ef54d 100644 --- a/CHANGELOG/CHANGELOG-0.1.md +++ b/CHANGELOG/CHANGELOG-0.1.md @@ -1,3 +1,15 @@ +# v0.1.4 + +## Changelog since v0.1.4 + +**Full Changelog**: https://github.com/Myriad-Dreamin/typst-book/compare/v0.1.3...v0.1.4 + +- (Fix) Specifying white space pre props in CSS in https://github.com/Myriad-Dreamin/typst-book/pull/54 +- (Fix) Improved `plain-text` by @ice1000 in https://github.com/Myriad-Dreamin/typst-book/pull/57 +- (Fix) Used `overflow-x: auto` by @ice1000 in https://github.com/Myriad-Dreamin/typst-book/pull/58 +- Performed null checking on creating labels in template in https://github.com/Myriad-Dreamin/typst-book/pull/59 + - You need to update your template to get this change. + # v0.1.3 ## Changelog since v0.1.3 diff --git a/Cargo.lock b/Cargo.lock index 3d70525..39cc726 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -802,7 +802,7 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.4" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d" dependencies = [ diff --git a/Cargo.toml b/Cargo.toml index 60ec677..7963495 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace.package] description = "A simple tool for creating modern online books in pure typst." authors = ["typst-book Developers"] -version = "0.1.3" +version = "0.1.4" edition = "2021" readme = "README.md" license = "Apache-2.0" diff --git a/cli/src/main.rs b/cli/src/main.rs index 93ac27b..f544496 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -100,7 +100,7 @@ async fn init(args: InitArgs) -> ZResult<()> { dir.join("book.typ"), format!( r##" -#import "@preview/book:0.2.4": * +#import "@preview/book:0.2.5": * #show: book @@ -135,7 +135,7 @@ Sample page write_file( dir.join("ebook.typ"), format!( - r##"#import "@preview/book:0.2.4": * + r##"#import "@preview/book:0.2.5": * #import "{ebook_template}" diff --git a/cli/src/project.rs b/cli/src/project.rs index 62fefa1..6020b8f 100644 --- a/cli/src/project.rs +++ b/cli/src/project.rs @@ -147,12 +147,12 @@ impl Project { let package_meta = res .first() - .ok_or_else(|| error_once!("no internal-package meta in book.typ (are you using old book package?, please import @preview/book:0.2.4; or do you forget the show rule `#show: book`?)"))?; + .ok_or_else(|| error_once!("no internal-package meta in book.typ (are you using old book package?, please import @preview/book:0.2.5; or do you forget the show rule `#show: book`?)"))?; let InternalPackageMeta::Package { version } = &package_meta.value; - if version != "0.2.4" { + if version != "0.2.5" { return Err(error_once!( - "outdated book package, please import @preview/book:0.2.4", importing_version: version, + "outdated book package, please import @preview/book:0.2.5", importing_version: version, )); } } diff --git a/contrib/typst/book/typst.toml b/contrib/typst/book/typst.toml index b7f6aeb..4047736 100644 --- a/contrib/typst/book/typst.toml +++ b/contrib/typst/book/typst.toml @@ -1,6 +1,6 @@ [package] name = "book" -version = "0.2.4" +version = "0.2.5" entrypoint = "lib.typ" authors = ["Myriad-Dreamin"] license = "Apache-2.0" diff --git a/contrib/typst/gh-ebook.typ b/contrib/typst/gh-ebook.typ index 242dc2f..32953da 100644 --- a/contrib/typst/gh-ebook.typ +++ b/contrib/typst/gh-ebook.typ @@ -1,4 +1,4 @@ -#import "@preview/book:0.2.4": * +#import "@preview/book:0.2.5": * #import "/contrib/typst/gh-pages.typ": project, part-style #let _page-project = project @@ -8,31 +8,29 @@ #let resolve-inclusion(inc) = _resolve-inclusion-state.update(it => inc) #let project(title: "", authors: (), spec: "", content) = { - set document(author: authors, title: title) - + set document( + author: authors, + title: title, + ) + // inherit from gh-pages show: _page-project - + if title != "" { heading(title) } - + locate(loc => { - let inc = _resolve-inclusion-state.final(loc) external-book(spec: inc(spec)) - + let mt = book-meta-state.final(loc) - let styles = ( - inc: inc, - part: part-style, - chapter: it => it, - ) - + let styles = (inc: inc, part: part-style, chapter: it => it) + if mt != none { mt.summary.map(it => visit-summary(it, styles)).sum() } }) - + content } \ No newline at end of file diff --git a/contrib/typst/gh-pages.typ b/contrib/typst/gh-pages.typ index 5251244..f0644a0 100644 --- a/contrib/typst/gh-pages.typ +++ b/contrib/typst/gh-pages.typ @@ -1,13 +1,17 @@ // This is important for typst-book to produce a responsive layout // and multiple targets. -#import "@preview/book:0.2.4": get-page-width, target, is-web-target, is-pdf-target, plain-text +#import "@preview/book:0.2.5": get-page-width, target, is-web-target, is-pdf-target, plain-text #let page-width = get-page-width() #let is-pdf-target = is-pdf-target() #let is-web-target = is-web-target() // todo: move theme style parser to another lib file -#let theme-target = if target.contains("-") { target.split("-").at(1) } else { "light" } +#let theme-target = if target.contains("-") { + target.split("-").at(1) +} else { + "light" +} #let theme-style = toml("theme-style.toml").at(theme-target) #let is-dark-theme = theme-style.at("color-scheme") == "dark" @@ -35,31 +39,25 @@ #let code-extra-colors = if code-theme-file.len() > 0 { let data = xml(theme-style.at("code-theme")).first() - + let find-child(elem, tag) = { elem.children.find(e => "tag" in e and e.tag == tag) } - + let find-kv(elem, key, tag) = { let idx = elem.children.position(e => "tag" in e and e.tag == "key" and e.children.first() == key) elem.children.slice(idx).find(e => "tag" in e and e.tag == tag) } - + let plist-dict = find-child(data, "dict") let plist-array = find-child(plist-dict, "array") let theme-setting = find-child(plist-array, "dict") let theme-setting-items = find-kv(theme-setting, "settings", "dict") let background-setting = find-kv(theme-setting-items, "background", "string") let foreground-setting = find-kv(theme-setting-items, "foreground", "string") - ( - bg: rgb(background-setting.children.first()), - fg: rgb(foreground-setting.children.first()), - ) + (bg: rgb(background-setting.children.first()), fg: rgb(foreground-setting.children.first())) } else { - ( - bg: rgb(239, 241, 243), - fg: none, - ) + (bg: rgb(239, 241, 243), fg: none) } #let make-unique-label(it, disambiguator: 1) = label({ @@ -77,17 +75,19 @@ // It takes your content and some metadata and formats it. // Go ahead and customize it to your liking! #let project(title: "Typst Book", authors: (), body) = { - // set basic document metadata - set document(author: authors, title: title) if not is-pdf-target - + set document( + author: authors, + title: title, + ) if not is-pdf-target + // set web/pdf page properties set page( - numbering: none, + numbering: none, number-align: center, width: page-width, ) - + // remove margins for web target set page( margin: ( @@ -101,50 +101,60 @@ // remove rest margins. rest: 0pt, ), - // for a website, we don't need pagination. height: auto, - ) if is-web-target; - + ) if is-web-target + // set text style - set text(font: main-font, size: 16pt, fill: main-color, lang: "en") - + set text( + font: main-font, + size: 16pt, + fill: main-color, + lang: "en", + ) + let ld = state("label-disambiguator", (:)) let update-ld(k) = ld.update(it => { - it.insert(k, it.at(k, default: 0) + 1); + it.insert(k, it.at(k, default: 0) + 1) it }) let get-ld(loc, k) = make-unique-label(k, disambiguator: ld.at(loc).at(k)) - + // render a dash to hint headings instead of bolding it. - show heading : set text(weight: "regular") if is-web-target - show heading : it => { + show heading: set text(weight: "regular") if is-web-target + show heading: it => { block({ if is-web-target { - let title = plain-text(it.body); + let title = plain-text(it.body) if title != none { - let title = title.trim(); + let title = title.trim() update-ld(title) - context ({ - let loc = here(); - let dest = get-ld(loc, title); - let h = measure(it.body).height; - place(left, dx: - 20pt, [ - #set text(fill: dash-color) - #link(loc)[\#] #dest - ]) - }); + context ( + { + let loc = here() + let dest = get-ld(loc, title) + let h = measure(it.body).height + place( + left, + dx: -20pt, + [ + #set text(fill: dash-color) + #link(loc)[\#] #dest + ], + ) + } + ) } } it }) } - + // link setting - show link : set text(fill: dash-color) - + show link: set text(fill: dash-color) + // math setting show math.equation: set text(weight: 400) - + // code block setting show raw: it => { set text(font: code-font) @@ -165,10 +175,10 @@ it } } - + // Main body. set par(justify: true) - + body } diff --git a/frontend/package.json b/frontend/package.json index 98b2188..8594ca8 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "typst-book", - "version": "0.1.3", + "version": "0.1.4", "description": "Typst Book.", "main": "dist/main.js", "repository": "https://github.com/Myriad-Dreamin/typst-book", diff --git a/github-pages/docs/book.typ b/github-pages/docs/book.typ index 8f1eab0..e579892 100644 --- a/github-pages/docs/book.typ +++ b/github-pages/docs/book.typ @@ -1,5 +1,5 @@ -#import "@preview/book:0.2.4": * +#import "@preview/book:0.2.5": * #show: book @@ -43,13 +43,11 @@ - #chapter(none)[Typst-side APIs] - #chapter(none)[typst-book CLI Internals] - #chapter(none)[Alternative Backends] - // end of summary - ] + // end of summary + ], ) -#build-meta( - dest-dir: "../dist", -) +#build-meta(dest-dir: "../dist") #get-book-meta() diff --git a/github-pages/docs/cli/init.typ b/github-pages/docs/cli/init.typ index d86dc91..0fcc287 100644 --- a/github-pages/docs/cli/init.typ +++ b/github-pages/docs/cli/init.typ @@ -32,7 +32,7 @@ typst-book build my-book/ # memoryized dest-dir The harder way, by creating the book without `init` command, your `book.typ` should at least provides a `book-meta`, as #cross-link("/guide/get-started.typ")[Get Started] shown. ```typ -#import "@preview/book:0.2.4": * +#import "@preview/book:0.2.5": * #show: book #book-meta( diff --git a/github-pages/docs/format/theme.typ b/github-pages/docs/format/theme.typ index 78ac7b2..4361162 100644 --- a/github-pages/docs/format/theme.typ +++ b/github-pages/docs/format/theme.typ @@ -17,7 +17,7 @@ Currently we have no much design on theme's html part. But you can still configu Your `book.typ` should at least provides a `book-meta`, as #t shown. ```typ -#import "@preview/book:0.2.4": * +#import "@preview/book:0.2.5": * #show: book #book-meta( diff --git a/github-pages/docs/guide/get-started.typ b/github-pages/docs/guide/get-started.typ index 53762ef..fcb7b87 100644 --- a/github-pages/docs/guide/get-started.typ +++ b/github-pages/docs/guide/get-started.typ @@ -48,7 +48,7 @@ Before a chapter can be viewed, it must be added to this list. Here's a basic summary file with a few chapters: ```typ -#import "@preview/book:0.2.4": * +#import "@preview/book:0.2.5": * #show: book #book-meta( // put metadata of your book like book.toml of mdbook diff --git a/github-pages/docs/pdf.typ b/github-pages/docs/pdf.typ index 90a8c36..758cd14 100644 --- a/github-pages/docs/pdf.typ +++ b/github-pages/docs/pdf.typ @@ -1,4 +1,4 @@ -#import "@preview/book:0.2.4": * +#import "@preview/book:0.2.5": * #import "/contrib/typst/gh-ebook.typ" #let ebook = gh-ebook