mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-12-23 08:47:50 +00:00
Some checks are pending
tinymist::ci / publish-vscode (push) Blocked by required conditions
tinymist::ci / build-vsc-assets (push) Blocked by required conditions
tinymist::ci / build-vscode (push) Blocked by required conditions
tinymist::ci / build-vscode-others (push) Blocked by required conditions
tinymist::ci / Duplicate Actions Detection (push) Waiting to run
tinymist::ci / Check Clippy, Formatting, Completion, Documentation, and Tests (Linux) (push) Waiting to run
tinymist::ci / Check Minimum Rust version and Tests (Windows) (push) Waiting to run
tinymist::ci / E2E Tests (darwin-arm64 on macos-latest) (push) Blocked by required conditions
tinymist::ci / E2E Tests (linux-x64 on ubuntu-22.04) (push) Blocked by required conditions
tinymist::ci / E2E Tests (linux-x64 on ubuntu-latest) (push) Blocked by required conditions
tinymist::ci / E2E Tests (win32-x64 on windows-2022) (push) Blocked by required conditions
tinymist::ci / E2E Tests (win32-x64 on windows-latest) (push) Blocked by required conditions
tinymist::ci / prepare-build (push) Waiting to run
tinymist::ci / build-binary (push) Blocked by required conditions
tinymist::gh_pages / build-gh-pages (push) Waiting to run
* feat: finally directly generate markdown files * fix: trim * fix: await
104 lines
2.8 KiB
Typst
104 lines
2.8 KiB
Typst
#import "@preview/shiroa:0.2.3": *
|
|
#import "/typ/templates/page.typ": heading-sizes, main-color, part-style, project
|
|
#import "tinymist-version.typ": tinymist-package
|
|
|
|
#let _page-project = project
|
|
|
|
#let _resolve-inclusion-state = state("_resolve-inclusion", none)
|
|
|
|
#let resolve-inclusion(inc) = _resolve-inclusion-state.update(it => inc)
|
|
|
|
#let project(title: "", authors: (), spec: "", body) = {
|
|
// Set document metadata early
|
|
set document(
|
|
author: authors,
|
|
title: title,
|
|
)
|
|
|
|
// Inherit from gh-pages
|
|
show: _page-project.with(title: title)
|
|
|
|
if title != "" {
|
|
set text(size: heading-sizes.at(1))
|
|
set text(weight: "bold")
|
|
|
|
// if kind == "page" and is-pdf-target and not is-main {
|
|
// [= #title]
|
|
// }
|
|
title
|
|
v(1em)
|
|
}
|
|
[
|
|
#tinymist-package.description
|
|
|
|
Visit tinymist repository: #link(tinymist-package.repository)[main branch, ] or #link({
|
|
tinymist-package.repository
|
|
"/tree/v"
|
|
tinymist-package.version
|
|
})[v#tinymist-package.version.]
|
|
]
|
|
|
|
{
|
|
// inherit from page setting
|
|
show: _page-project.with(title: none, kind: "preface")
|
|
|
|
include "/typ/templates/license.typ"
|
|
|
|
let outline-numbering-base = numbering.with("1.")
|
|
let outline-numbering(a0, ..args) = if a0 > 0 {
|
|
h(1em * args.pos().len())
|
|
outline-numbering-base(a0, ..args) + [ ]
|
|
}
|
|
|
|
let outline-counter = counter("outline-counter")
|
|
show outline.entry: it => {
|
|
let has-part = if it.body().func() != none and "children" in it.body().fields() {
|
|
for ch in it.body().children {
|
|
if "text" in ch.fields() and ch.text.contains("Part") {
|
|
ch.text
|
|
}
|
|
}
|
|
}
|
|
|
|
// set link(main-color)
|
|
show link: set text(fill: main-color)
|
|
|
|
if has-part == none {
|
|
if it.element.numbering == none {
|
|
outline-counter.step(level: it.level + 1)
|
|
} else {
|
|
outline-counter.step(level: it.level + 2)
|
|
}
|
|
layout(shape => {
|
|
context {
|
|
let lnk = link(it.element.location(), [#outline-counter.display(outline-numbering) #it.element.body])
|
|
let r = repeat([.])
|
|
let page-no = str(it.element.location().page())
|
|
let q = measure(lnk + page-no)
|
|
lnk
|
|
box(width: shape.width - q.width, inset: (x: 0.25em), r)
|
|
page-no
|
|
}
|
|
})
|
|
} else {
|
|
outline-counter.step(level: 1)
|
|
block(link(it.element.location(), it.element.body))
|
|
}
|
|
}
|
|
|
|
set outline.entry(fill: repeat[.])
|
|
outline(depth: 1)
|
|
}
|
|
|
|
body
|
|
|
|
context {
|
|
let inc = _resolve-inclusion-state.final()
|
|
let mt = book-meta-state.final()
|
|
let styles = (inc: inc, part: part-style, chapter: it => it)
|
|
|
|
if mt != none {
|
|
mt.summary.map(it => visit-summary(it, styles)).sum()
|
|
}
|
|
}
|
|
}
|