From af46f0d0ac336f5359ea4797fdb51af3ea2157db Mon Sep 17 00:00:00 2001 From: Myriad-Dreamin <35292584+Myriad-Dreamin@users.noreply.github.com> Date: Sat, 15 Jun 2024 06:34:30 +0800 Subject: [PATCH] feat: rename the repository to shiroa (for publish) (#73) --- .github/workflows/ci.yaml | 4 +- .github/workflows/docker.yaml | 2 +- .github/workflows/gh_pages.yml | 4 +- .github/workflows/lint_pr_title.yml | 2 +- .github/workflows/release.yaml | 56 +++---- .github/workflows/release_with_artifact.yaml | 58 +++---- Cargo.lock | 68 ++++----- Cargo.toml | 6 +- Dockerfile | 4 +- README.md | 30 ++-- cli/Cargo.toml | 6 +- cli/src/lib.rs | 6 +- cli/src/main.rs | 4 +- cli/src/project.rs | 8 +- cli/src/utils.rs | 2 +- cli/src/version.rs | 2 +- contrib/typst/book/lib.typ | 144 ++++++++++-------- contrib/typst/gh-pages.typ | 32 ++-- contrib/typst/variables/lib.typ | 2 +- frontend/package.json | 6 +- github-pages/docs/book.typ | 10 +- github-pages/docs/cli/build.typ | 12 +- github-pages/docs/cli/init.typ | 12 +- github-pages/docs/cli/main.typ | 14 +- github-pages/docs/cli/serve.typ | 10 +- github-pages/docs/format/book-meta.typ | 117 +++++++------- github-pages/docs/format/book.typ | 8 +- github-pages/docs/format/build-meta.typ | 2 +- .../docs/format/supports/sema-desc.typ | 8 +- github-pages/docs/format/theme.typ | 6 +- github-pages/docs/guide/faq.typ | 2 +- github-pages/docs/guide/get-started.typ | 30 ++-- github-pages/docs/guide/installation.typ | 20 +-- github-pages/docs/introduction.typ | 12 +- themes/mdbook/index.hbs | 22 +-- themes/mdbook/index.js | 8 +- tools/build-from-source/Cargo.toml | 4 +- 37 files changed, 377 insertions(+), 366 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e1cfb92..2d325d8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: typst_book::ci +name: shiroa::ci on: [push, pull_request] env: @@ -27,6 +27,6 @@ jobs: cargo build --release --workspace - name: Build Book run: | - cargo run --release --bin typst-book -- build --path-to-root /typst-book/ -w . github-pages/docs + cargo run --release --bin shiroa -- build --path-to-root /shiroa/ -w . github-pages/docs - name: Test run: cargo test --workspace --no-fail-fast diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 51d1eed..d5346b9 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -1,4 +1,4 @@ -name: typst_book::release::docker +name: shiroa::release::docker on: release: types: [created] diff --git a/.github/workflows/gh_pages.yml b/.github/workflows/gh_pages.yml index 899e2e3..a0ea8e1 100644 --- a/.github/workflows/gh_pages.yml +++ b/.github/workflows/gh_pages.yml @@ -34,7 +34,7 @@ jobs: - name: Download font assets run: | mkdir -p assets/fonts - curl -L https://github.com/Myriad-Dreamin/typst-book/releases/download/v0.1.0/charter-font-assets.tar.gz | tar -xvz -C assets/fonts + curl -L https://github.com/Myriad-Dreamin/shiroa/releases/download/v0.1.0/charter-font-assets.tar.gz | tar -xvz -C assets/fonts - name: Install Rust uses: dtolnay/rust-toolchain@stable - name: Set Node.js 18.x @@ -45,7 +45,7 @@ jobs: uses: Swatinem/rust-cache@v2 - name: Build Book run: | - cargo run --release --bin typst-book -- build --font-path assets/fonts --path-to-root /typst-book/ -w . github-pages/docs + cargo run --release --bin shiroa -- build --font-path assets/fonts --path-to-root /shiroa/ -w . github-pages/docs - name: Setup Pages uses: actions/configure-pages@v3 - name: Upload artifact diff --git a/.github/workflows/lint_pr_title.yml b/.github/workflows/lint_pr_title.yml index 3f9577b..b018699 100644 --- a/.github/workflows/lint_pr_title.yml +++ b/.github/workflows/lint_pr_title.yml @@ -1,4 +1,4 @@ -name: typst_book::lint_pr_title +name: shiroa::lint_pr_title on: pull_request: types: [opened, edited, synchronize] diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 5a97b45..f31a4ab 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: typst_book::release +name: shiroa::release on: release: types: [created] @@ -38,7 +38,7 @@ jobs: if-no-files-found: error - uses: actions/upload-artifact@v3 with: - name: typst-book-dist + name: shiroa-dist path: frontend/dist if-no-files-found: error @@ -118,17 +118,17 @@ jobs: - name: Run Native Build shell: pwsh run: | - cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin typst-book - cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin typst-book + cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin shiroa + cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin shiroa - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }} - path: target/${{ matrix.rust-target }}/release-stripped/typst-book* + name: shiroa-${{ env.target }} + path: target/${{ matrix.rust-target }}/release-stripped/shiroa* if-no-files-found: error - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }}-relwithdebuginfo - path: target/${{ matrix.rust-target }}/release/typst-book* + name: shiroa-${{ env.target }}-relwithdebuginfo + path: target/${{ matrix.rust-target }}/release/shiroa* if-no-files-found: error build_linux_riscv64: @@ -157,16 +157,16 @@ jobs: target: ${{ matrix.rust-target }} - name: Build cross image run: | - docker build -t typst-book/riscv64 ${GITHUB_WORKSPACE}/.github/cross-linux-riscv64/ + docker build -t shiroa/riscv64 ${GITHUB_WORKSPACE}/.github/cross-linux-riscv64/ env: CROSS_DOCKER_IN_DOCKER: true - name: Run Cross Build run: | mkdir -p frontend/node_modules cp -r artifacts/typst-ts-dist frontend/node_modules/@myriaddreamin - cp -r artifacts/typst-book-dist frontend/dist - docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project typst-book/riscv64:latest cargo build --manifest-path cli/Cargo.toml --release --target ${CARGO_TARGET} --bin typst-book - docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project typst-book/riscv64:latest cargo build --manifest-path cli/Cargo.toml --profile release-stripped --target ${CARGO_TARGET} --bin typst-book + cp -r artifacts/shiroa-dist frontend/dist + docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project shiroa/riscv64:latest cargo build --manifest-path cli/Cargo.toml --release --target ${CARGO_TARGET} --bin shiroa + docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project shiroa/riscv64:latest cargo build --manifest-path cli/Cargo.toml --profile release-stripped --target ${CARGO_TARGET} --bin shiroa env: CROSS_DOCKER_IN_DOCKER: true CARGO_TARGET: ${{ matrix.rust-target }} @@ -174,13 +174,13 @@ jobs: PKG_CONFIG_ALLOW_CROSS: true - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }} - path: target/${{ matrix.rust-target }}/release-stripped/typst-book* + name: shiroa-${{ env.target }} + path: target/${{ matrix.rust-target }}/release-stripped/shiroa* if-no-files-found: error - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }}-relwithdebuginfo - path: target/${{ matrix.rust-target }}/release/typst-book* + name: shiroa-${{ env.target }}-relwithdebuginfo + path: target/${{ matrix.rust-target }}/release/shiroa* if-no-files-found: error build_alpine: @@ -220,17 +220,17 @@ jobs: dir: 'frontend' - name: build binaries run: | - cargo build --release --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin typst-book - cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin typst-book + cargo build --release --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin shiroa + cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin shiroa - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }} - path: target/${{ env.RUST_TARGET }}/release-stripped/typst-book* + name: shiroa-${{ env.target }} + path: target/${{ env.RUST_TARGET }}/release-stripped/shiroa* if-no-files-found: error - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }}-relwithdebuginfo - path: target/${{ env.RUST_TARGET }}/release/typst-book* + name: shiroa-${{ env.target }}-relwithdebuginfo + path: target/${{ env.RUST_TARGET }}/release/shiroa* if-no-files-found: error release: @@ -253,32 +253,32 @@ jobs: mkdir -p gh-release/ pack_release() { target=$2 - src=typst-book-$1 - name=typst-book-$target + src=shiroa-$1 + name=shiroa-$target mkdir -p tmp/$name rm -f artifacts/$src/*.d rm -f artifacts/$src/*.pdb mkdir -p release/$name/bin - cp artifacts/$src-relwithdebuginfo/typst-book* "release/$name/bin/" + cp artifacts/$src-relwithdebuginfo/shiroa* "release/$name/bin/" cp -r CHANGELOG release/$name/ cp -r github-pages/docs release/$name/ cp README.md \ LICENSE \ CHANGELOG.md \ release/$name/ - chmod +x release/$name/bin/typst-book* + chmod +x release/$name/bin/shiroa* tar czvf gh-release/$name-relwithdebuginfo.tar.gz -C release $name mkdir -p release-stripped/$name/bin - cp artifacts/$src/typst-book* "release-stripped/$name/bin/" + cp artifacts/$src/shiroa* "release-stripped/$name/bin/" cp -r CHANGELOG release-stripped/$name/ cp -r github-pages/docs release-stripped/$name/ cp README.md \ LICENSE \ CHANGELOG.md \ release-stripped/$name/ - chmod +x release-stripped/$name/bin/typst-book* + chmod +x release-stripped/$name/bin/shiroa* tar czvf gh-release/$name.tar.gz -C release-stripped $name } pack_release win32-x64 x86_64-pc-windows-msvc diff --git a/.github/workflows/release_with_artifact.yaml b/.github/workflows/release_with_artifact.yaml index 6c44a8a..2369673 100644 --- a/.github/workflows/release_with_artifact.yaml +++ b/.github/workflows/release_with_artifact.yaml @@ -1,4 +1,4 @@ -name: typst_book::release_with_artifact +name: shiroa::release_with_artifact on: workflow_dispatch: @@ -73,17 +73,17 @@ jobs: - name: Run Native Build shell: pwsh run: | - cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin typst-book - cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin typst-book + cargo build --release --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin shiroa + cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target ${{ matrix.rust-target }} --bin shiroa - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }} - path: target/${{ matrix.rust-target }}/release-stripped/typst-book* + name: shiroa-${{ env.target }} + path: target/${{ matrix.rust-target }}/release-stripped/shiroa* if-no-files-found: error - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }}-relwithdebuginfo - path: target/${{ matrix.rust-target }}/release/typst-book* + name: shiroa-${{ env.target }}-relwithdebuginfo + path: target/${{ matrix.rust-target }}/release/shiroa* if-no-files-found: error build_linux_riscv64: @@ -111,14 +111,14 @@ jobs: target: ${{ matrix.rust-target }} - name: Build cross image run: | - docker build -t typst-book/riscv64 ${GITHUB_WORKSPACE}/.github/cross-linux-riscv64/ + docker build -t shiroa/riscv64 ${GITHUB_WORKSPACE}/.github/cross-linux-riscv64/ env: CROSS_DOCKER_IN_DOCKER: true - name: Run Cross Build run: | mkdir -p frontend/node_modules - docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project typst-book/riscv64:latest cargo build --manifest-path cli/Cargo.toml --release --target ${CARGO_TARGET} --bin typst-book - docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project typst-book/riscv64:latest cargo build --manifest-path cli/Cargo.toml --profile release-stripped --target ${CARGO_TARGET} --bin typst-book + docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project shiroa/riscv64:latest cargo build --manifest-path cli/Cargo.toml --release --target ${CARGO_TARGET} --bin shiroa + docker run -v /var/run/docker.sock:/var/run/docker.sock -v ${GITHUB_WORKSPACE}:/project -w /project shiroa/riscv64:latest cargo build --manifest-path cli/Cargo.toml --profile release-stripped --target ${CARGO_TARGET} --bin shiroa env: CROSS_DOCKER_IN_DOCKER: true CARGO_TARGET: ${{ matrix.rust-target }} @@ -126,13 +126,13 @@ jobs: PKG_CONFIG_ALLOW_CROSS: true - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }} - path: target/${{ matrix.rust-target }}/release-stripped/typst-book* + name: shiroa-${{ env.target }} + path: target/${{ matrix.rust-target }}/release-stripped/shiroa* if-no-files-found: error - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }}-relwithdebuginfo - path: target/${{ matrix.rust-target }}/release/typst-book* + name: shiroa-${{ env.target }}-relwithdebuginfo + path: target/${{ matrix.rust-target }}/release/shiroa* if-no-files-found: error build_alpine: @@ -160,22 +160,22 @@ jobs: git config --global --add safe.directory $PWD - name: build binaries run: | - cargo build --release --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin typst-book - cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin typst-book + cargo build --release --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin shiroa + cargo build --profile release-stripped --manifest-path cli/Cargo.toml --target $RUST_TARGET --bin shiroa - uses: actions/upload-artifact@v3 with: - name: typst-book-font-assets + name: shiroa-font-assets path: assets if-no-files-found: error - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }} - path: target/${{ env.RUST_TARGET }}/release-stripped/typst-book* + name: shiroa-${{ env.target }} + path: target/${{ env.RUST_TARGET }}/release-stripped/shiroa* if-no-files-found: error - uses: actions/upload-artifact@v3 with: - name: typst-book-${{ env.target }}-relwithdebuginfo - path: target/${{ env.RUST_TARGET }}/release/typst-book* + name: shiroa-${{ env.target }}-relwithdebuginfo + path: target/${{ env.RUST_TARGET }}/release/shiroa* if-no-files-found: error release: @@ -198,32 +198,32 @@ jobs: mkdir -p gh-release/ pack_release() { target=$2 - src=typst-book-$1 - name=typst-book-$target + src=shiroa-$1 + name=shiroa-$target mkdir -p tmp/$name rm -f artifacts/$src/*.d rm -f artifacts/$src/*.pdb mkdir -p release/$name/bin - cp artifacts/$src-relwithdebuginfo/typst-book* "release/$name/bin/" + cp artifacts/$src-relwithdebuginfo/shiroa* "release/$name/bin/" cp -r CHANGELOG release/$name/ cp -r github-pages/docs release/$name/ cp README.md \ LICENSE \ CHANGELOG.md \ release/$name/ - chmod +x release/$name/bin/typst-book* + chmod +x release/$name/bin/shiroa* tar czvf gh-release/$name-relwithdebuginfo.tar.gz -C release $name mkdir -p release-stripped/$name/bin - cp artifacts/$src/typst-book* "release-stripped/$name/bin/" + cp artifacts/$src/shiroa* "release-stripped/$name/bin/" cp -r CHANGELOG release-stripped/$name/ cp -r github-pages/docs release-stripped/$name/ cp README.md \ LICENSE \ CHANGELOG.md \ release-stripped/$name/ - chmod +x release-stripped/$name/bin/typst-book* + chmod +x release-stripped/$name/bin/shiroa* tar czvf gh-release/$name.tar.gz -C release-stripped $name } pack_release win32-x64 x86_64-pc-windows-msvc @@ -238,9 +238,9 @@ jobs: pack_release alpine-x64 alpine-x64 pack_release alpine-x64 x86_64-unknown-linux-musl - # typst-book-font-assets + # shiroa-font-assets mkdir -p release/font-assets - cp -r artifacts/typst-book-font-assets/* release/font-assets/ + cp -r artifacts/shiroa-font-assets/* release/font-assets/ tar czvf gh-release/font-assets.tar.gz -C release font-assets - name: Display structure of releasing files run: find gh-release diff --git a/Cargo.lock b/Cargo.lock index 02f488e..096b6a4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2903,6 +2903,40 @@ dependencies = [ "digest", ] +[[package]] +name = "shiroa-build" +version = "0.1.5" +dependencies = [ + "anyhow", +] + +[[package]] +name = "shiroa-cli" +version = "0.1.5" +dependencies = [ + "anyhow", + "clap", + "clap_complete", + "clap_complete_fig", + "comemo", + "env_logger", + "handlebars", + "include_dir", + "log", + "pathdiff", + "serde", + "serde_json", + "tokio", + "toml", + "typst", + "typst-assets", + "typst-ts-compiler", + "typst-ts-core", + "typst-ts-svg-exporter", + "vergen", + "warp", +] + [[package]] name = "signal-hook-registry" version = "1.4.1" @@ -3582,40 +3616,6 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b3061f8d268e8eec7481c9ab24540455cb4912983c49aae38fa6e8bf8ef4d9c" -[[package]] -name = "typst-book-build" -version = "0.1.5" -dependencies = [ - "anyhow", -] - -[[package]] -name = "typst-book-cli" -version = "0.1.5" -dependencies = [ - "anyhow", - "clap", - "clap_complete", - "clap_complete_fig", - "comemo", - "env_logger", - "handlebars", - "include_dir", - "log", - "pathdiff", - "serde", - "serde_json", - "tokio", - "toml", - "typst", - "typst-assets", - "typst-ts-compiler", - "typst-ts-core", - "typst-ts-svg-exporter", - "vergen", - "warp", -] - [[package]] name = "typst-macros" version = "0.11.1" diff --git a/Cargo.toml b/Cargo.toml index 347cb24..9e84279 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [workspace.package] description = "A simple tool for creating modern online books in pure typst." -authors = ["typst-book Developers"] +authors = ["shiroa Developers"] version = "0.1.5" edition = "2021" readme = "README.md" license = "Apache-2.0" -homepage = "https://github.com/Myriad-Dreamin/typst-book" -repository = "https://github.com/Myriad-Dreamin/typst-book" +homepage = "https://github.com/Myriad-Dreamin/shiroa" +repository = "https://github.com/Myriad-Dreamin/shiroa" [workspace] diff --git a/Dockerfile b/Dockerfile index 772c083..3320ba2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,8 +14,8 @@ WORKDIR /app COPY --from=build-yarn /app/frontend /app/frontend ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse RUN apt-get install -y git \ - && cargo build -p typst-book-cli --release + && cargo build -p shiroa-cli --release FROM debian:11 WORKDIR /root/ -COPY --from=build /app/target/release/typst-book /bin +COPY --from=build /app/target/release/shiroa /bin diff --git a/README.md b/README.md index b228365..b64d193 100644 --- a/README.md +++ b/README.md @@ -1,57 +1,57 @@ -# typst-book +# shiroa -A simple tool for creating modern online books in pure typst. +_shiroa_ (_Shiro A_, or _The White_, or _云笺_) is a simple tool for creating modern online (cloud) books in pure typst. -## Installation (typst-book CLI) +## Installation (shiroa CLI) -There are multiple ways to install the typst-book CLI tool. +There are multiple ways to install the shiroa CLI tool. Choose any one of the methods below that best suit your needs. ### Pre-compiled binaries -Executable binaries are available for download on the [GitHub Releases page](https://github.com/Myriad-Dreamin/typst-book/releases). +Executable binaries are available for download on the [GitHub Releases page](https://github.com/Myriad-Dreamin/shiroa/releases). Download the binary for your platform (Windows, macOS, or Linux) and extract the archive. -The archive contains an `typst-book` executable which you can run to build your books. +The archive contains an `shiroa` executable which you can run to build your books. To make it easier to run, put the path to the binary into your `PATH`. ### Build from source using Rust -To build the `typst-book` executable from source, you will first need to install Yarn, Rust, and Cargo. +To build the `shiroa` executable from source, you will first need to install Yarn, Rust, and Cargo. Follow the instructions on the [Yarn installation page](https://classic.yarnpkg.com/en/docs/install) and [Rust installation page](https://www.rust-lang.org/tools/install). -typst-book currently requires at least Rust version 1.75. +shiroa currently requires at least Rust version 1.75. To build with precompiled artifacts, run the following commands: ```sh -cargo install --git https://github.com/Myriad-Dreamin/typst-book --locked typst-book-cli +cargo install --git https://github.com/Myriad-Dreamin/shiroa --locked shiroa-cli ``` To build from source, run the following commands: ```sh -git clone https://github.com/Myriad-Dreamin/typst-book.git +git clone https://github.com/Myriad-Dreamin/shiroa.git git submodule update --recursive --init -cargo run --bin typst-book-build +cargo run --bin shiroa-build # optional: install it globally cargo install --path ./cli ``` -With global installation, to uninstall, run the command `cargo uninstall typst-book`. +With global installation, to uninstall, run the command `cargo uninstall shiroa`. Again, make sure to add the Cargo bin directory to your `PATH`. ### Get started -See the [Get-started](https://myriad-dreamin.github.io/typst-book/guide/get-started.html) online documentation. +See the [Get-started](https://myriad-dreamin.github.io/shiroa/guide/get-started.html) online documentation. ### Setup for writing your book -We don't provide a watch command, but `typst-book` is designated to embracing all of the approaches to writing typst documents. It's feasible to preview your documents by following approaches (like previewing normal documents): +We don't provide a watch command, but `shiroa` is designated to embracing all of the approaches to writing typst documents. It's feasible to preview your documents by following approaches (like previewing normal documents): - (Waiting for ready) once supporting local packages, you can write the book via [Official Web App](https://typst.app). -- via VSCod(e,ium), see [Typst LSP](https://marketplace.visualstudio.com/items?itemName=nvarner.typst-lsp) and [Typst Preview](https://marketplace.visualstudio.com/items?itemName=mgt19937.typst-preview). +- via VSCod(e,ium), see [Tinymist](https://marketplace.visualstudio.com/items?itemName=myriad-dreamin.tinymist) and [Typst Preview](https://marketplace.visualstudio.com/items?itemName=mgt19937.typst-preview). - via other editors. For example of neovim, see [typst.vim](https://github.com/kaarmu/typst.vim) and [Typst Preview](https://github.com/Enter-tainer/typst-preview#use-without-vscode). diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 442b43f..313a836 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "typst-book-cli" -description = "Command line tool for typst-book." +name = "shiroa-cli" +description = "Command line tool for shiroa." authors.workspace = true version.workspace = true license.workspace = true @@ -9,7 +9,7 @@ homepage.workspace = true repository.workspace = true [[bin]] -name = "typst-book" +name = "shiroa" path = "src/main.rs" test = false doctest = false diff --git a/cli/src/lib.rs b/cli/src/lib.rs index c8852ca..0abd018 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -12,7 +12,7 @@ use std::path::PathBuf; use clap::{ArgAction, Parser, Subcommand}; #[derive(Debug, Parser)] -#[clap(name = "typst-book", version = "0.1.0")] +#[clap(name = "shiroa", version = "0.1.0")] pub struct Opts { /// Print Version #[arg(short = 'V', long, group = "version-dump")] @@ -28,7 +28,7 @@ pub struct Opts { #[derive(Debug, Subcommand)] #[clap( - about = "The cli for typst-book.", + about = "The cli for shiroa.", after_help = "", next_display_order = None )] @@ -58,7 +58,7 @@ pub struct CompileArgs { /// Output to directory, default in the same directory as the entry file. /// Relative paths are interpreted relative to the book's root directory. - /// If omitted, typst-book uses build.build-dir from book.toml or defaults + /// If omitted, shiroa uses build.build-dir from book.toml or defaults /// to `./dist`. #[clap(long, short, default_value = "")] pub dest_dir: String, diff --git a/cli/src/main.rs b/cli/src/main.rs index f544496..bd84f2f 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -1,7 +1,7 @@ use std::{net::SocketAddr, path::Path, process::exit}; use clap::{Args, Command, FromArgMatches}; -use typst_book_cli::{ +use shiroa_cli::{ error::prelude::*, project::Project, utils::{async_continue, create_dirs, make_absolute, write_file, UnwrapOrExit}, @@ -105,7 +105,7 @@ async fn init(args: InitArgs) -> ZResult<()> { #show: book #book-meta( - title: "typst-book", + title: "shiroa", summary: [ #prefix-chapter("sample-page.typ")[Hello, typst] ] diff --git a/cli/src/project.rs b/cli/src/project.rs index 5cd64de..596be4a 100644 --- a/cli/src/project.rs +++ b/cli/src/project.rs @@ -142,7 +142,7 @@ impl Project { let res = self .tr .compiler - .query("".to_string(), &doc); + .query("".to_string(), &doc); let res = self .tr .report(res) @@ -172,7 +172,7 @@ impl Project { let res = self .tr .compiler - .query("".to_string(), &doc); + .query("".to_string(), &doc); let res = self .tr .report(res) @@ -197,7 +197,7 @@ impl Project { let res = self .tr .compiler - .query("".to_string(), &doc); + .query("".to_string(), &doc); let res = self .tr .report(res) @@ -243,7 +243,7 @@ impl Project { include_bytes!("../../assets/artifacts/svg_utils.cjs"), )?; write_file( - self.dest_dir.join("internal/typst-book.js"), + self.dest_dir.join("internal/shiroa.js"), include_bytes!("../../assets/artifacts/book.mjs"), )?; diff --git a/cli/src/utils.rs b/cli/src/utils.rs index 870d0cb..c8db5e0 100644 --- a/cli/src/utils.rs +++ b/cli/src/utils.rs @@ -21,7 +21,7 @@ pub fn async_continue>(f: F) -> ! { pub fn exit_with_error(err: E) -> ! { clap::Error::raw( clap::error::ErrorKind::ValueValidation, - format!("typst-book error: {}", err), + format!("shiroa error: {}", err), ) .exit() } diff --git a/cli/src/version.rs b/cli/src/version.rs index 4e3b6f9..dc63ca3 100644 --- a/cli/src/version.rs +++ b/cli/src/version.rs @@ -45,7 +45,7 @@ impl VersionInfo { fn new() -> Self { Self { // todo: global app name - name: "typst-book", + name: "shiroa", version: VERSION, features: env!("VERGEN_CARGO_FEATURES").split(',').collect::>(), diff --git a/contrib/typst/book/lib.typ b/contrib/typst/book/lib.typ index 7946f6a..00ce61d 100644 --- a/contrib/typst/book/lib.typ +++ b/contrib/typst/book/lib.typ @@ -21,10 +21,10 @@ #let book-meta-state = state("book-meta", none) /// helper function to get (and print/use) the final book metadata -#let get-book-meta() = _labeled-meta() +#let get-book-meta() = _labeled-meta() /// helper function to get (and print/use) the final build metadata -#let get-build-meta() = _labeled-meta() +#let get-build-meta() = _labeled-meta() /// Book metadata in summary.typ /// @@ -47,16 +47,16 @@ language: "", // default "en" summary: none, ) = [ - #metadata(( - kind: "book", - title: title, - description: description, - repository: repository, - repository_edit: repository-edit, - authors: authors, - language: language, - summary: summary, - )) + #metadata(( + kind: "book", + title: title, + description: description, + repository: repository, + repository_edit: repository-edit, + authors: authors, + language: language, + summary: summary, + )) ] /// Build metadata in summary.typ @@ -64,14 +64,14 @@ /// the book's root directory. This can overridden with the --dest-dir CLI /// option. #let build-meta( - dest-dir: "", + dest-dir: "", ) = [ - #metadata(( - "dest-dir": dest-dir - )) + #metadata(( + "dest-dir": dest-dir, + )) ] -#let link2page = state("typst-book-link2page", (:)) +#let link2page = state("shiroa-link2page", (:)) #let encode-url-component(s) = { let prev = false @@ -113,7 +113,7 @@ } if reference != none { - let result = query(reference, loc); + let result = query(reference, loc) // whether it is internal link if result.len() > 0 { link(reference, content) @@ -122,20 +122,23 @@ } // assert(read(path) != none, message: "no such file") - link({ - "cross-link://jump?path-label=" - path-lbl - if reference != none { - "&label=" - encode-url-component(str(reference)) - } - }, content) + link( + { + "cross-link://jump?path-label=" + path-lbl + if reference != none { + "&label=" + encode-url-component(str(reference)) + } + }, + content, + ) }) } // Collect text content of element recursively into a single string // https://discord.com/channels/1054443721975922748/1088371919725793360/1138586827708702810 -// https://github.com/Myriad-Dreamin/typst-book/issues/55 +// https://github.com/Myriad-Dreamin/shiroa/issues/55 #let _styled = smallcaps("").func(); #let _equation = $1$.func(); #let _sequence = [].func(); @@ -153,7 +156,11 @@ } else if f == text or f == raw { it.text } else if f == smartquote { - if it.double { "\"" } else { "'" } + if it.double { + "\"" + } else { + "'" + } } else if f == _sequence { it.children.map(plain-text).filter(t => type(t) == str).join() } else { @@ -191,10 +198,10 @@ /// #chapter("chapter2.typ", section: "1.2")["Chapter 1.2"] /// ``` #let chapter(link, title, section: auto) = metadata(( - kind: "chapter", - link: link, - section: section, - title: _store-content(title), + kind: "chapter", + link: link, + section: section, + title: _store-content(title), )) /// Represents a prefix/suffix chapter in the book @@ -210,7 +217,7 @@ /// Represents a divider in the summary sidebar #let divider = metadata(( - kind: "divider" + kind: "divider", )) /// Internal method to convert summary content nodes @@ -218,14 +225,14 @@ // The entry point of the metadata nodes if metadata == elem.func() { - + // convert any metadata elem to its value let node = elem.value // Convert the summary content inside the book elem if node.at("kind") == "book" { - let summary = node.at("summary") - node.insert("summary", _convert-summary(summary)) + let summary = node.at("summary") + node.insert("summary", _convert-summary(summary)) } return node @@ -234,9 +241,9 @@ // convert a heading element to a part elem if heading == elem.func() { return ( - kind: "part", - level: elem.depth, - title: _store-content(elem.body), + kind: "part", + level: elem.depth, + title: _store-content(elem.body), ) } @@ -247,23 +254,23 @@ let maybe-children = _convert-summary(elem.body) if type(maybe-children) == "array" { - // if the list-item has children, then process subchapters + // if the list-item has children, then process subchapters - if maybe-children.len() <= 0 { - panic("invalid list-item, no maybe-children") - } + if maybe-children.len() <= 0 { + panic("invalid list-item, no maybe-children") + } - // the first child is the chapter itself - let node = maybe-children.at(0) + // the first child is the chapter itself + let node = maybe-children.at(0) - // the rest are subchapters - let rest = maybe-children.slice(1) - node.insert("sub", rest) + // the rest are subchapters + let rest = maybe-children.slice(1) + node.insert("sub", rest) - return node + return node } else { - // no children, return the list-item itself - return maybe-children + // no children, return the list-item itself + return maybe-children } } @@ -285,14 +292,14 @@ for c in meta { // skip non-chapter nodes or nodes without section number if c.at("kind") != "chapter" or c.at("section") == none { - (c, ) + (c,) continue } // default incremental section let idx = cnt cnt += 1 - let num = base + (idx, ) + let num = base + (idx,) // c.insert("auto-section", num) let user-specified = c.at("section") @@ -307,9 +314,12 @@ user-specified.split(".").map(int) } else if type(user-specified) == array { for n in user-specified { - assert(type(n) == int, message: "invalid type of section counter specified " + repr(user-specified) + ", want number in array") + assert( + type(n) == int, + message: "invalid type of section counter specified " + repr(user-specified) + ", want number in array", + ) } - + // e.g. (1, 2, 3) user-specified } else { @@ -318,7 +328,7 @@ // update cnt cnt = num.last() + 1 - } + } // update section number let auto-num = num.map(str).join(".") @@ -329,7 +339,7 @@ c.sub = _numbering-sections(c.at("sub"), base: num) } - (c, ) + (c,) } } @@ -340,16 +350,16 @@ /// ``` #let book(content) = { // set page(width: 300pt, margin: (left: 10pt, right: 10pt, rest: 0pt)) - [#metadata(toml("typst.toml")) ] + [#metadata(toml("typst.toml")) ] locate(loc => { - let data = query(, loc).at(0) + let data = query(, loc).at(0) let meta = _convert-summary(data) meta.at("summary") = _numbering-sections(meta.at("summary")) book-meta-state.update(meta) [ - #metadata(meta) + #metadata(meta) ] }) @@ -357,14 +367,16 @@ // node // } // #sidebar-gen(converted) -// #get-book-meta() + // #get-book-meta() content } #let external-book(spec: none) = { - place(hide[ - #spec - ]) + place( + hide[ + #spec + ], + ) } #let visit-summary(x, visit) = { @@ -389,7 +401,7 @@ } } - show : it => { + show: it => { let abs-link = cross-link-path-label("/" + link) locate(loc => { link2page.update(it => { @@ -400,7 +412,7 @@ it } - + visit.at("chapter")(chapter-content) } diff --git a/contrib/typst/gh-pages.typ b/contrib/typst/gh-pages.typ index f0644a0..5ff9389 100644 --- a/contrib/typst/gh-pages.typ +++ b/contrib/typst/gh-pages.typ @@ -1,4 +1,4 @@ -// This is important for typst-book to produce a responsive layout +// This is important for shiroa to produce a responsive layout // and multiple targets. #import "@preview/book:0.2.5": get-page-width, target, is-web-target, is-pdf-target, plain-text @@ -24,13 +24,13 @@ "Charter", "Source Han Serif SC", "Source Han Serif TC", - // typst-book's embedded font + // shiroa's embedded font "Linux Libertine", ) #let code-font = ( "BlexMono Nerd Font Mono", - // typst-book's embedded font + // shiroa's embedded font "DejaVu Sans Mono", ) @@ -39,16 +39,16 @@ #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") @@ -80,14 +80,14 @@ author: authors, title: title, ) if not is-pdf-target - + // set web/pdf page properties set page( numbering: none, number-align: center, width: page-width, ) - + // remove margins for web target set page( margin: ( @@ -103,7 +103,7 @@ ), height: auto, ) if is-web-target - + // set text style set text( font: main-font, @@ -111,14 +111,14 @@ 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 }) 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 => { @@ -148,13 +148,13 @@ it }) } - + // link setting 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) @@ -175,10 +175,10 @@ it } } - + // Main body. set par(justify: true) - + body } diff --git a/contrib/typst/variables/lib.typ b/contrib/typst/variables/lib.typ index fb73339..afd2db0 100644 --- a/contrib/typst/variables/lib.typ +++ b/contrib/typst/variables/lib.typ @@ -1,5 +1,5 @@ //! This is a stub package for typst.ts's dyn-svg controlling the layout -//! Here is a good example of dynamic layout template: +//! Here is a good example of dynamic layout template: /// default target is "pdf", typst.ts will set it to "web" when rendering to a /// dynamic layout diff --git a/frontend/package.json b/frontend/package.json index 9edee0f..208061c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,12 +1,12 @@ { - "name": "typst-book", + "name": "shiroa", "version": "0.1.5", "description": "Typst Book.", "main": "dist/main.js", - "repository": "https://github.com/Myriad-Dreamin/typst-book", + "repository": "https://github.com/Myriad-Dreamin/shiroa", "author": "Myriad-Dreamin", "contributors": [ - "typst-book Developers" + "shiroa Developers" ], "scripts": { "build": "tsc && vite build", diff --git a/github-pages/docs/book.typ b/github-pages/docs/book.typ index e579892..8dfdfc0 100644 --- a/github-pages/docs/book.typ +++ b/github-pages/docs/book.typ @@ -4,10 +4,10 @@ #show: book #book-meta( - title: "typst-book", - description: "typst-book Documentation", - repository: "https://github.com/Myriad-Dreamin/typst-book", - repository-edit: "https://github.com/Myriad-Dreamin/typst-book/edit/main/github-pages/docs/{path}", + title: "shiroa", + description: "shiroa Documentation", + repository: "https://github.com/Myriad-Dreamin/shiroa", + repository-edit: "https://github.com/Myriad-Dreamin/shiroa/edit/main/github-pages/docs/{path}", authors: ("Myriad-Dreamin", "7mile"), language: "en", summary: [ // begin of summary @@ -41,7 +41,7 @@ - #chapter("format/supports/sema-desc.typ")[Semantic Page Description] - #chapter(none)[For developers] - #chapter(none)[Typst-side APIs] - - #chapter(none)[typst-book CLI Internals] + - #chapter(none)[shiroa CLI Internals] - #chapter(none)[Alternative Backends] // end of summary ], diff --git a/github-pages/docs/cli/build.typ b/github-pages/docs/cli/build.typ index 7f2e6cc..48831bb 100644 --- a/github-pages/docs/cli/build.typ +++ b/github-pages/docs/cli/build.typ @@ -7,7 +7,7 @@ The build command is used to render your book: ```bash -typst-book build +shiroa build ``` It will try to parse your `book.typ` file to understand the structure and metadata @@ -23,19 +23,19 @@ The `build` command can take a directory as an argument to use as the book's root instead of the current working directory. ```bash -typst-book build path/to/book +shiroa build path/to/book ``` === --workspace, -w *Note:* The workspace is a _typst-specific_ command. -The `--workspace` option specifies the root directory of typst source files, which is like the `--root` option of `typst-cli`. It is interpreted relative to *current work directory of `typst-book` process*. +The `--workspace` option specifies the root directory of typst source files, which is like the `--root` option of `typst-cli`. It is interpreted relative to *current work directory of `shiroa` process*. For example. When a book is created with the main file `book-project1/book.typ`, and you want to access a template file with path `common/book-template.typ`, please build it with following command: ```bash -typst-book build -w . book-project1 +shiroa build -w . book-project1 ``` Then you can access the template with the absolute path in typst: @@ -53,10 +53,10 @@ not specified it will default to the value of the `build.build-dir` key in === --path-to-root -When your website's root is not exact serving the book, use `--path-to-root` to specify the path to the root of the book site. For example, if you own `myriad-dreamin.github.io` and have mounted the book to `/typst-book/`, you can access `https://myriad-dreamin.github.io/typst-book/cli/main.html` to get the generated content of `cli/main.typ`. +When your website's root is not exact serving the book, use `--path-to-root` to specify the path to the root of the book site. For example, if you own `myriad-dreamin.github.io` and have mounted the book to `/shiroa/`, you can access `https://myriad-dreamin.github.io/shiroa/cli/main.html` to get the generated content of `cli/main.typ`. ```bash -typst-book build --path-to-root /typst-book/ book-project1 +shiroa build --path-to-root /shiroa/ book-project1 ``` // #line(length: 100%) diff --git a/github-pages/docs/cli/init.typ b/github-pages/docs/cli/init.typ index 0fcc287..5b2ce8c 100644 --- a/github-pages/docs/cli/init.typ +++ b/github-pages/docs/cli/init.typ @@ -9,22 +9,22 @@ The `init` command will try to initialize your book to build your book successfu For instance, Initialize a book to the directory `my-book`: ```bash -typst-book init my-book/ -typst-book build my-book/ +shiroa init my-book/ +shiroa build my-book/ ``` Initialize a book with specific typst workspace directory: ```bash -typst-book init -w . my-book/ -typst-book build -w . my-book/ +shiroa init -w . my-book/ +shiroa build -w . my-book/ ``` Initialize a book with specific `dest-dir`: ```bash -typst-book init --dest-dir ../dist my-book/ -typst-book build my-book/ # memoryized dest-dir +shiroa init --dest-dir ../dist my-book/ +shiroa build my-book/ # memoryized dest-dir ``` == Things to note diff --git a/github-pages/docs/cli/main.typ b/github-pages/docs/cli/main.typ index 53244df..de6181f 100644 --- a/github-pages/docs/cli/main.typ +++ b/github-pages/docs/cli/main.typ @@ -5,17 +5,17 @@ = Command Line Tool // todo: cross link -The `typst-book` command-line tool is used to create and build books. -After you have #cross-link("/guide/installation.typ")[installed] `typst-book`, you can run the `typst-book help` command in your terminal to view the available commands. +The `shiroa` command-line tool is used to create and build books. +After you have #cross-link("/guide/installation.typ")[installed] `shiroa`, you can run the `shiroa help` command in your terminal to view the available commands. This following sections provide in-depth information on the different commands available. // todo: cross link -- #cross-link("/cli/init.typ")[`typst-book init `] — Creates a new book with minimal boilerplate to start with. -- #cross-link("/cli/build.typ")[`typst-book build`] — Renders the book. -- #cross-link("/cli/serve.typ")[`typst-book serve`] — Runs a web server to view the book, and rebuilds on changes. -- #cross-link("/cli/clean.typ")[`typst-book clean`] — Deletes the rendered output. -- #cross-link("/cli/completions.typ")[`typst-book completions`] — Support for shell auto-completion. +- #cross-link("/cli/init.typ")[`shiroa init `] — Creates a new book with minimal boilerplate to start with. +- #cross-link("/cli/build.typ")[`shiroa build`] — Renders the book. +- #cross-link("/cli/serve.typ")[`shiroa serve`] — Runs a web server to view the book, and rebuilds on changes. +- #cross-link("/cli/clean.typ")[`shiroa clean`] — Deletes the rendered output. +- #cross-link("/cli/completions.typ")[`shiroa completions`] — Support for shell auto-completion. = Note about the missing `watch` command diff --git a/github-pages/docs/cli/serve.typ b/github-pages/docs/cli/serve.typ index 8762132..7efc8fa 100644 --- a/github-pages/docs/cli/serve.typ +++ b/github-pages/docs/cli/serve.typ @@ -5,10 +5,10 @@ = The serve command The serve command is used to preview a book by serving it via HTTP at -`localhost:25520` by default: +`localhost:25520` by default: ```bash -typst-book serve +shiroa serve ``` // The `serve` command watches the book's `src` directory for @@ -25,7 +25,7 @@ The `serve` command can take a directory as an argument to use as the book's root instead of the current working directory. ```bash -typst-book serve path/to/book +shiroa serve path/to/book ``` == Build options @@ -37,12 +37,12 @@ The `serve` command will build your book once before serving the content. It is The `serve` address defaults to `localhost:25520`. Either option can be specified on the command line: ```bash -typst-book serve path/to/book --addr 8000:127.0.0.1 +shiroa serve path/to/book --addr 8000:127.0.0.1 ``` === --open -When you use the `--open` flag, typst-book will open the rendered book in +When you use the `--open` flag, shiroa will open the rendered book in your default web browser after building it. // == Specify exclude patterns diff --git a/github-pages/docs/format/book-meta.typ b/github-pages/docs/format/book-meta.typ index 2836d7f..a136b97 100644 --- a/github-pages/docs/format/book-meta.typ +++ b/github-pages/docs/format/book-meta.typ @@ -12,8 +12,8 @@ } } { - // show "<": set text(fill: blue) - // show ">": set text(fill: blue) + // show "<": set text(fill: blue) + // show ">": set text(fill: blue) text(fill: red, raw(t)) } } @@ -59,76 +59,75 @@ to be ignored at best, or may cause an error when attempting to build the book. ``` + ***Prefix Chapter*** - Before the main numbered chapters, prefix chapters can be added - that will not be numbered. This is useful for forewords, - introductions, etc. There are, however, some constraints. Prefix chapters cannot be - nested; they should all be on the root level. And you cannot add - prefix chapters once you have added numbered chapters. - ```typ - #prefix-chapter("pre.typ")[Prefix Chapter] - - #chapter("1.typ", section: "1")[First Chapter] - ``` + that will not be numbered. This is useful for forewords, + introductions, etc. There are, however, some constraints. Prefix chapters cannot be + nested; they should all be on the root level. And you cannot add + prefix chapters once you have added numbered chapters. + ```typ + #prefix-chapter("pre.typ")[Prefix Chapter] + - #chapter("1.typ", section: "1")[First Chapter] + ``` + ***Part Title*** - Headers can be used as a title for the following numbered - chapters. This can be used to logically separate different sections - of the book. The title is rendered as unclickable text. - Titles are optional, and the numbered chapters can be broken into as many - parts as desired. - ```typ - = My Part Title + chapters. This can be used to logically separate different sections + of the book. The title is rendered as unclickable text. + Titles are optional, and the numbered chapters can be broken into as many + parts as desired. + ```typ + = My Part Title - - #chapter("1.typ", section: "1")[First Chapter] - ``` + - #chapter("1.typ", section: "1")[First Chapter] + ``` + ***Numbered Chapter*** - Numbered chapters outline the main content of the book - and can be nested, resulting in a nice hierarchy - (chapters, sub-chapters, etc.). - ```typ - = Title of Part + and can be nested, resulting in a nice hierarchy + (chapters, sub-chapters, etc.). + ```typ + = Title of Part - - #chapter("first.typ", section: "1")[First Chapter] - - #chapter("first-sub-chapter.typ", section: "1.1")[First sub-chapter] - - #chapter("second.typ", section: "1")[Second Chapter] + - #chapter("first.typ", section: "1")[First Chapter] + - #chapter("first-sub-chapter.typ", section: "1.1")[First sub-chapter] + - #chapter("second.typ", section: "1")[Second Chapter] - = Title of Another Part + = Title of Another Part - - #chapter("another/chapter.typ", section: "1")[Another Chapter] - ``` - Numbered chapters can be denoted either `-`. - -+ ***Suffix Chapter*** - Like prefix chapters, suffix chapters are unnumbered, but they come after - numbered chapters. - ```typ - = Last Part + - #chapter("another/chapter.typ", section: "1")[Another Chapter] + ``` + Numbered chapters can be denoted either `-`. - - #chapter("second.typ", section: "10")[Last Chapter] ++ ***Suffix Chapter*** - Like prefix chapters, suffix chapters are unnumbered, but they come after + numbered chapters. + ```typ + = Last Part - #suffix-chapter("suf.typ")[Title of Suffix Chapter] - ``` + - #chapter("second.typ", section: "10")[Last Chapter] + + #suffix-chapter("suf.typ")[Title of Suffix Chapter] + ``` + ***Draft chapters*** - Draft chapters are chapters without a file and thus content. - The purpose of a draft chapter is to signal future chapters still to be written. - Or when still laying out the structure of the book to avoid creating the files - while you are still changing the structure of the book a lot. - Draft chapters will be rendered in the HTML renderer as disabled links in the table - of contents, as you can see for the next chapter in the table of contents on the left. - Draft chapters are written like normal chapters but without writing the path to the file. - ```typ - #chapter(none, section: "5.2")[Draft Chapter] - ``` + The purpose of a draft chapter is to signal future chapters still to be written. + Or when still laying out the structure of the book to avoid creating the files + while you are still changing the structure of the book a lot. + Draft chapters will be rendered in the HTML renderer as disabled links in the table + of contents, as you can see for the next chapter in the table of contents on the left. + Draft chapters are written like normal chapters but without writing the path to the file. + ```typ + #chapter(none, section: "5.2")[Draft Chapter] + ``` + ***Separators*** - Separators can be added before, in between, and after any other element. They result - in an HTML rendered line in the built table of contents. A separator is - a line containing exclusively dashes and at least three of them: `---`. - ```typ - = My Part Title - - #prefix-chapter("pre.typ")[A Prefix Chapter] + in an HTML rendered line in the built table of contents. A separator is + a line containing exclusively dashes and at least three of them: `---`. + ```typ + = My Part Title + + #prefix-chapter("pre.typ")[A Prefix Chapter] - #divider() + #divider() - - #chapter("1.typ", section: "1")[First Chapter] - ``` - + - #chapter("1.typ", section: "1")[First Chapter] + ``` == Example @@ -139,7 +138,7 @@ of contents as rendered to the left. let exp = read("../book.typ") let exp = exp.find(regex("// begin of summary[\s\S]*// end of summary")).split("\n") // remove first and last line (begin and end of summary) - let exp = exp.slice(1, exp.len()-2) + let exp = exp.slice(1, exp.len() - 2) // remove leading spaces let space = exp.at(0).position("#") let exp = exp.map(it => it.slice(space)) @@ -158,7 +157,7 @@ A description for the book, which is added as meta information in the html ` - - {{!-- --}} + + {{!-- --}} @@ -124,15 +124,15 @@ localStorage.removeItem('mdbook-sidebar'); } catch (e) { } try { - var theme = localStorage.getItem('typst-book-theme'); - var sidebar = localStorage.getItem('typst-book-sidebar'); + var theme = localStorage.getItem('shiroa-theme'); + var sidebar = localStorage.getItem('shiroa-sidebar'); if (theme.startsWith('"') && theme.endsWith('"')) { - localStorage.setItem('typst-book-theme', theme.slice(1, theme.length - 1)); + localStorage.setItem('shiroa-theme', theme.slice(1, theme.length - 1)); } if (sidebar.startsWith('"') && sidebar.endsWith('"')) { - localStorage.setItem('typst-book-sidebar', sidebar.slice(1, sidebar.length - 1)); + localStorage.setItem('shiroa-sidebar', sidebar.slice(1, sidebar.length - 1)); } } catch (e) { } @@ -141,7 +141,7 @@