Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to typst v0.10.0, texmath v0.12.8.6 #60

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/auto-release-typst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
sudo apt-get install curl git unzip imagemagick libwebp-dev librsvg2-dev fonts-noto-cjk fonts-noto-cjk-extra
sudo apt-get remove fonts-noto-color-emoji

curl -OL https://github.com/typst/typst/releases/download/v0.9.0/typst-x86_64-unknown-linux-musl.tar.xz
curl -OL https://github.com/megakite/texmath/releases/download/v0.12.8.3-20231003/texmath-arg
curl -OL https://github.com/typst/typst/releases/download/v0.10.0/typst-x86_64-unknown-linux-musl.tar.xz
curl -OL https://github.com/megakite/texmath/releases/download/v0.12.8.6-20231213/texmath-arg
xz -dc typst-x86_64-unknown-linux-musl.tar.xz | tar -x
sudo mv ./typst-x86_64-unknown-linux-musl/typst /bin/
chmod +x texmath-arg
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-build-typst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
sudo apt-get install curl git unzip imagemagick libwebp-dev librsvg2-dev fonts-noto-cjk fonts-noto-cjk-extra
sudo apt-get remove fonts-noto-color-emoji

curl -OL https://github.com/typst/typst/releases/download/v0.9.0/typst-x86_64-unknown-linux-musl.tar.xz
curl -OL https://github.com/megakite/texmath/releases/download/v0.12.8.3-20231003/texmath-arg
curl -OL https://github.com/typst/typst/releases/download/v0.10.0/typst-x86_64-unknown-linux-musl.tar.xz
curl -OL https://github.com/megakite/texmath/releases/download/v0.12.8.6-20231213/texmath-arg
xz -dc typst-x86_64-unknown-linux-musl.tar.xz | tar -x
sudo mv ./typst-x86_64-unknown-linux-musl/typst /bin/
chmod +x texmath-arg
Expand Down
9 changes: 9 additions & 0 deletions oi-wiki-export-typst/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,16 @@ async function main() {
result += '{0} {1}\n'.format('='.repeat(depth + 1), escape(key))
} else {
labelHistory.push(dirName)
if (depth === 0) {
result += `#import "../oi-wiki.typ": page-header
#pagebreak(to: "odd", weak: true)
#set page(header: none)
`
}
result += '{0} {1} <{2}>\n'.format('='.repeat(depth + 1), escape(key), dirName)
if (depth === 0) {
result += '#set page(header: page-header)\n'
}
}

for (const id in object[key]) {
Expand Down
63 changes: 2 additions & 61 deletions oi-wiki-export-typst/oi-wiki-export.typ
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/* BEGIN imports */
#import "constants.typ": *
#import "oi-wiki.typ": page-header
/* END imports */

/* BEGIN meta */
Expand Down Expand Up @@ -136,72 +137,12 @@

/* BEGIN main */
#set page(
header: locate(loc => {
if calc.odd(loc.page()) {
// NOTE: not able to programatically hide headings on new chapters for now
// issue: https://github.com/typst/typst/issues/1613

let section = query(
selector(heading.where(level: 2)).before(loc),
loc
)
if section == () {
return none
}

let sect-number(..headings) = {
let levels = headings.pos()

if levels.len() > 1 {
[#levels.at(0).#levels.at(1)]
} else {
none
}
}

text(9pt, number-width: "tabular")[
#emph[
#counter(heading).display(sect-number)
#h(1em)
#smallcaps(section.last().body)
]
#h(1fr)
#counter(page).display("1")
]
} else {
let chapters = query(
selector(heading.where(level: 1)).before(loc),
loc,
)
// HACK: don't add headers in outlines (Chapter 0)
// This is only a workaround. Detailed mechanism of typst's pagebreaks
// needs to be further researched.
let chapter-counter = counter(heading.where(level: 1)).at(loc)
if chapter-counter == (0,) {
return none
}

text(9pt, number-width: "tabular")[
#counter(page).display("1")
#h(1fr)
第#counter(heading.where(level: 1)).display("一")章
#h(1em)
#chapters.last().body
]
}
})
header: page-header
)

#counter(page).update(1)

#show heading.where(level: 1): it => {
set page(
header: none,
//fill: luma(95%),
)

pagebreak(to: "odd", weak: true)

set text(
25pt,
font: ("New Computer Modern", "Noto Serif CJK SC"),
Expand Down
55 changes: 55 additions & 0 deletions oi-wiki-export-typst/oi-wiki.typ
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,61 @@
#import "@preview/tiaoma:0.1.0"
/* END imports */

#let page-header = locate(loc => {
if calc.odd(loc.page()) {
// NOTE: not able to programatically hide headings on new chapters for now
// issue: https://github.com/typst/typst/issues/1613

let section = query(
selector(heading.where(level: 2)).before(loc),
loc
)
if section == () {
return none
}

let sect-number(..headings) = {
let levels = headings.pos()

if levels.len() > 1 {
[#levels.at(0).#levels.at(1)]
} else {
none
}
}

text(9pt, number-width: "tabular")[
#emph[
#counter(heading).display(sect-number)
#h(1em)
#smallcaps(section.last().body)
]
#h(1fr)
#counter(page).display("1")
]
} else {
let chapters = query(
selector(heading.where(level: 1)).before(loc),
loc,
)
// HACK: don't add headers in outlines (Chapter 0)
// This is only a workaround. Detailed mechanism of typst's pagebreaks
// needs to be further researched.
let chapter-counter = counter(heading.where(level: 1)).at(loc)
if chapter-counter == (0,) {
return none
}

text(9pt, number-width: "tabular")[
#counter(page).display("1")
#h(1fr)
第#counter(heading.where(level: 1)).display("一")章
#h(1em)
#chapters.last().body
]
}
}
)

#let horizontalrule = align(center, block(
sym.ast.op + h(1em) + sym.ast.op + h(1em) + sym.ast.op
Expand Down
Loading