Skip to content

Commit

Permalink
chore: upgrade typst template (#86)
Browse files Browse the repository at this point in the history
* chore: upgrade template

* remove submodule and directly embed code

* chore: bump to 0.12

* better fonts and source code block

* breakable detail, compact link array, list indent

* ci: add font download

* zebra style code block

* checkin crimson text font

* upgrade to latest mitex
  • Loading branch information
Enter-tainer authored Jan 7, 2025
1 parent 4527343 commit 66e086b
Show file tree
Hide file tree
Showing 67 changed files with 11,472 additions and 335 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/auto-release-typst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- uses: typst-community/setup-typst@v3
with:
typst-version: 0.11.1
typst-version: 0.12.0
cache-dependency-path: oi-wiki-export-typst/oi-wiki.typ

- name: Pre-build operations
Expand All @@ -38,6 +38,7 @@ jobs:
mkdir .fonts
curl -L $(gh api /repos/lxgw/LxgwWenKai/releases/latest -q '.assets[].browser_download_url | select(contains("tar.gz"))') | tar xfz - -C .fonts
cp -r oi-wiki-export-typst/fonts/* .fonts
git clone https://github.com/OI-wiki/OI-wiki.git --depth=1 --single-branch -b master
cd remark-typst
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-build-typst.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: typst-community/setup-typst@v3
with:
typst-version: 0.11.1
typst-version: 0.12.0
cache-dependency-path: oi-wiki-export-typst/oi-wiki.typ

- name: Pre-build operations
Expand All @@ -39,7 +39,8 @@ jobs:
mkdir .fonts
curl -L $(gh api /repos/lxgw/LxgwWenKai/releases/latest -q '.assets[].browser_download_url | select(contains("tar.gz"))') | tar xfz - -C .fonts
cp -r oi-wiki-export-typst/fonts/* .fonts
git clone https://github.com/OI-wiki/OI-wiki.git --depth=1 --single-branch -b master
cd remark-typst
npm install
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "remark-typst"]
path = remark-typst
url = https://github.com/OI-Wiki/remark-typst.git
22 changes: 19 additions & 3 deletions oi-wiki-export-typst/constants.typ
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,24 @@
// Default text size of raw block is 0.8rem
// So we scale it back a little (equivalent to 9pt)
// issue: https://github.com/typst/typst/issues/1331
#let RAW_EM = 1.125em
#let RAW_EM = 1.1em
#let en-font = "Crimson"

// Page dimensions minus margin
#let VISIBLE_WIDTH = 21cm - 1in
#let VISIBLE_HEIGHT = 29.7cm - 1.5in
#let serif-font = (
en-font,
"Noto Serif CJK SC",
"Source Han Serif SC",
)
#let sans-font = (
en-font,
"Noto Sans CJK SC",
"Source Han Sans SC",
)
#let emph-font = (en-font, "LXGW Wenkai")
#let raw-font = ("DejaVu Sans Mono", "Noto Sans CJK SC", "Source Han Sans SC")
#let math-font = (
"New Computer Modern Math",
"Noto Serif CJK SC",
"Source Han Serif SC",
)
Binary file added oi-wiki-export-typst/fonts/CrimsonText-Bold.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
93 changes: 93 additions & 0 deletions oi-wiki-export-typst/fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2010 The Crimson Text Project Authors (https://github.com/googlefonts/Crimson)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
104 changes: 52 additions & 52 deletions oi-wiki-export-typst/oi-wiki-export.typ
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
#import "constants.typ": *
#import "oi-wiki.typ": page-header
/* END imports */
#show ref: it => {
if query(it.target).len() == 0 {
return text(fill: red, "<未找到引用" + str(it.target) + ">")
}
it
}

/* BEGIN meta */
#set text(
Expand All @@ -16,27 +22,33 @@
#set page(
header: none,
paper: "a4",
margin: (top: .8in, inside: .4in, bottom: .7in, outside: .6in),
header-ascent: .3in,
fill: luma(95%),
)

#align(center + horizon)[
// OI-Wiki logo
#image.decode("<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 3 1 9l11 6 9-4.91V17h2V9M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82Z\"></path></svg>", height: 4cm)
#image.decode(
"<svg viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12 3 1 9l11 6 9-4.91V17h2V9M5 13.18v4L12 21l7-3.82v-4L12 17l-7-3.82Z\"></path></svg>",
height: 4cm,
)
#text(
25pt,
font: ("New Computer Modern", "Noto Serif CJK SC"),
font: serif-font,
weight: 700,
)[OI Wiki (Beta)]
#v(4cm)
#text(
18pt,
font: ("New Computer Modern", "Noto Serif CJK SC"),
font: serif-font,
)[
OI Wiki 项目组

#datetime.today().display("[year] 年 [month padding:none] 月 [day padding:none] 日")
#(
datetime
.today()
.display("[year] 年 [month padding:none] 月 [day padding:none] 日")
)
]
]

Expand All @@ -56,7 +68,7 @@

#set text(
ROOT_EM,
font: ("New Computer Modern", "Noto Serif CJK SC"),
font: serif-font,
)

#set par(
Expand All @@ -66,13 +78,16 @@
// issues: https://github.com/typst/typst/issues/311
// https://github.com/typst/typst/issues/1410
// first-line-indent: 2em,
linebreaks: "optimized",
justify: true,
)
#show raw.where(block: true): set par(justify: false)

#set block(spacing: .8em)

#set strong(delta: 0)
#show strong: set text(
font: ("New Computer Modern", "Noto Sans CJK SC"),
font: sans-font,
// New Computer Modern: 400 |----->700
// Noto Sans CJK: 400 500<-| 700
// DejaVu Sans Mono: 400 |----->700
Expand All @@ -82,75 +97,63 @@
)

#set heading(numbering: "1.1")
#show heading: set block(spacing: 0em)
#show heading: set text(
font: ("New Computer Modern", "Noto Sans CJK SC"),
font: sans-font,
weight: 551,
)
#show heading.where(level: 1): set text(25pt)
#show heading.where(level: 2): set text(20pt)
#show heading.where(level: 3): set text(17pt)
#show heading.where(level: 4): set text(14pt)
#show heading.where(level: 5): set text(12pt)
#show heading.where(level: 6): set text(10pt)
#show heading: it => {
// NOTE: dynamic spacing?
// v(1fr, weak: true)
v(1.4em)
it
v(.2em)
}
#show heading.where(level: 1): set text(18pt)
#show heading.where(level: 2): it => {
v(2em)
align(center)[#it]
v(2em)
set text(16pt)
v(1em, weak: true)
align(center, it)
v(1em, weak: true)
}
#show heading.where(level: 3): it => {
set text(14pt)
v(1em, weak: true)
it
v(1em, weak: true)
}
#show heading.where(level: 4): set text(12pt)
#show heading.where(level: 5): set text(11pt)
#show heading.where(level: 6): set text(10pt)

#show emph: set text(
font: ("New Computer Modern", "LXGW Wenkai")
)
#show emph: set text(font: emph-font)

#show math.equation: set text(
font: ("New Computer Modern Math", "LXGW Wenkai")
)
#show math.equation: set text(font: math-font)

#show raw: set text(
RAW_EM,
font: ("DejaVu Sans Mono", "LXGW Wenkai"),
font: raw-font,
)

#show raw.where(block: false): it => highlight(
fill: luma(95%),
it
it,
)
/* END article formatting */

/* BEGIN outline */
#show outline.entry.where(
level: 1
): it => {
v(20pt, weak: true)
text(14pt)[#strong(it)]
#show outline.entry.where(level: 1): it => {
v(2em, weak: true)
text(12pt, font: sans-font, it)
}

#outline(indent: auto)
#outline(indent: 2em)
/* END outline */

/* BEGIN main */
#set page(
header: page-header
)
#set page(header: page-header)

#counter(page).update(1)

#show heading.where(level: 1): it => {
set text(
25pt,
font: ("New Computer Modern", "Noto Serif CJK SC"),
font: serif-font,
weight: 700,
)
set par(
first-line-indent: 0em,
)
set par(first-line-indent: 0em)

align(horizon)[
#counter(heading).display("一")章
Expand All @@ -170,13 +173,11 @@
// of bullet: 778 units
// of whitespace: 333 units
#set list(
indent: 1em,
body-indent: -.778em + 1em,
indent: 2em,
)
#show list: set block(width: 100%)
#set enum(
indent: 1em,
body-indent: -.5em -.278em + 1em,
indent: 2em,
)
#show enum: set block(width: 100%)

Expand All @@ -185,7 +186,6 @@

#show footnote.entry: it => {
set text(9pt)
show parbreak: none
it
}

Expand All @@ -202,6 +202,6 @@

#align(
center + horizon,
text(17pt)[https://oi-wiki.org]
text(17pt)[https://oi-wiki.org],
)
/* END back cover */
Loading

0 comments on commit 66e086b

Please sign in to comment.