Skip to content

Commit

Permalink
build: bump version to 0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Apr 4, 2024
1 parent 9537c20 commit 5e128fa
Show file tree
Hide file tree
Showing 15 changed files with 97 additions and 79 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions CHANGELOG/CHANGELOG-0.1.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
4 changes: 2 additions & 2 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
6 changes: 3 additions & 3 deletions cli/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
));
}
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/typst/book/typst.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
26 changes: 12 additions & 14 deletions contrib/typst/gh-ebook.typ
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
}
98 changes: 54 additions & 44 deletions contrib/typst/gh-pages.typ
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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({
Expand All @@ -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: (
Expand All @@ -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)
Expand All @@ -165,10 +175,10 @@
it
}
}

// Main body.
set par(justify: true)

body
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 4 additions & 6 deletions github-pages/docs/book.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#import "@preview/book:0.2.4": *
#import "@preview/book:0.2.5": *

#show: book

Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion github-pages/docs/cli/init.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion github-pages/docs/format/theme.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion github-pages/docs/guide/get-started.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion github-pages/docs/pdf.typ
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5e128fa

Please sign in to comment.