Skip to content

Commit 7f07536

Browse files
Merge pull request #82 from YDX-2147483647/cron
2 parents 9989221 + 70e5fad commit 7f07536

File tree

5 files changed

+104
-12
lines changed

5 files changed

+104
-12
lines changed

README.en.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,24 @@ The meanings of `<<< ` and `>>>` are the same as those in simple examples.
249249
@book{key,
250250
title = {标题},
251251
author = {作者},
252-
year = {2025}
252+
date = {2025}
253253
}
254254
% 作者. 标题. 2025.
255255
```
256+
257+
```example-bib
258+
key:
259+
type: book
260+
title: 标题
261+
author: 作者
262+
date: 2025
263+
# 作者. 标题. 2025.
264+
```
256265
````
257266

258-
- Regular lines: BibTeX entries.
267+
- Regular lines: BibTeX/YAML entries.
259268

260-
- Lines starting with `%`: Expected output.
269+
- Lines starting with `%`/`#`: Expected output.
261270

262271
## License
263272

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,24 @@ simple example 执行于容器中,且会在整篇文档中共享状态。
252252
@book{key,
253253
title = {标题},
254254
author = {作者},
255-
year = {2025}
255+
date = {2025}
256256
}
257257
% 作者. 标题. 2025.
258258
```
259+
260+
```example-bib
261+
key:
262+
type: book
263+
title: 标题
264+
author: 作者
265+
date: 2025
266+
# 作者. 标题. 2025.
267+
```
259268
````
260269

261-
- 普通行:BibTeX 项目。
270+
- 普通行:BibTeX/YAML 项目。
262271

263-
- `%`打头的行:预期输出。
272+
- `%`/`#`打头的行:预期输出。
264273

265274
## 许可
266275

main.typ

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,6 +985,32 @@ $ f(x) = y "(定义8)" $
985985
>>> ]
986986
```
987987

988+
=== #bbl(en: [Customize punctuation width], zh: [定制标点宽度]) <customize-punct-width>
989+
990+
#level.advanced
991+
#issue("typst#7643")
992+
993+
#babel(
994+
en: [Currently, typst controls the punctuation width based on `text.region`, but sometimes further customization is required.],
995+
zh: [当前 typst 会根据`text.region`控制标点宽度,但有时还需进一步定制。],
996+
)
997+
998+
```example-page
999+
>>> Current & Expected: \
1000+
#set text(region: "HK")
1001+
(甲乙丙丁)\ (甲乙丙?)\ (甲乙?丁)
1002+
1003+
>>> Current & Expected: \
1004+
#set text(region: "CN")
1005+
(甲乙丙丁)\ (甲乙丙?)\ (甲乙?丁)
1006+
1007+
>>> Expected: \
1008+
// Expected to be possible:
1009+
<<< #set text(punct-style: "plain")
1010+
<<< (甲乙丙丁)\ (甲乙丙?)\ (甲乙?丁)
1011+
>>> (甲乙丙丁)\ (甲乙丙#box(width: 1em)[?])\ (甲乙?丁)
1012+
```
1013+
9881014
=== #bbl(en: [Two-em dashes are overhung], zh: [破折号被错误悬挂]) <two-em-dash-overhung>
9891015

9901016
#level.basic
@@ -1851,6 +1877,31 @@ $ integral f dif x $
18511877
% 不二咲千尋. 基于图书室的笔记本电脑的 Alter Ego 系统[D]. 某地: 私立希望ヶ峰学園, 2010: 1–3, 5.
18521878
```
18531879

1880+
=== #bbl(en: [`第1卷` is incorrectly treated as numeric], zh: [`第1卷`被错当为数值]) <csl-is-numeric>
1881+
1882+
#level.advanced
1883+
#issue("hayagriva#439")
1884+
1885+
#babel(
1886+
en: [The `volume` field of an entry can be either numeric (e.g., `2`, `2a`) or non-numeric (e.g., `第2卷`, `2nd volume`), and the CSL style may use ```xml <if is-numeric="volume">``` to implement conditional rendering.],
1887+
zh: [条目的`volume`字段既可能是数值(例:`2``2a`),也可能并非数值(例:`第2卷``2nd volume`)。CSL 样式可用```xml <if is-numeric="volume">```实现条件渲染。],
1888+
)
1889+
1890+
#babel(
1891+
en: [However, typst distinguishes _non-numeric contents_ from _numbers with suffixes_ by scanning whitespaces. As a result, it treats `第1卷` as numeric incorrectly, generating a redundant `卷`.],
1892+
zh: [然而,typst 通过扫描空格来区分“非数值内容”与“带后缀的数字”,于是`第1卷`被错当为数值,生成多余`卷`字。],
1893+
)
1894+
1895+
```example-bib
1896+
gbt7714.04.1.2:01.simplified:
1897+
type: book
1898+
title: 国史旧闻
1899+
volume: 第2卷
1900+
author:
1901+
- 陈登原
1902+
# 陈登原. 国史旧闻: 第2卷[M].
1903+
```
1904+
18541905
=== #bbl(
18551906
en: [Chinese works should be ordered by the pinyin or strokes of the authors for `gb-7714-2015-author-date`],
18561907
zh: [采用`gb-7714-2015-author-date`时,中文文献应按著者汉语拼音字顺或笔画笔顺排列],
@@ -1920,6 +1971,7 @@ $ integral f dif x $
19201971

19211972
#level.basic
19221973
#issue("hayagriva#312")
1974+
#issue("tzhtaylor/modern-sjtu-thesis#9")
19231975

19241976
#babel(
19251977
en: [`@standard` is the `[S]` type in GB/T 7714—2015. It is #link("https://docs.citationstyles.org/en/stable/specification.html#appendix-iii-types")[a regular type in CSL], and a non-standard type in BibTeX (but accepted by biber). However, typst interprets it as `@misc` (`[Z]`) or `@webpage` (`[EB]`).],
@@ -1937,7 +1989,23 @@ $ integral f dif x $
19371989
pubstate = {Published},
19381990
version = {5},
19391991
}
1940-
% ISO/IEC. Information Technology — Dynamic Adaptive Streaming over HTTP (DASH) — Part 1: Media Presentation Description and Segment Formats[S/OL]. International Organization for Standardization, 2022. https://www.iso.org/standard/83314.html. Published.
1992+
% ISO/IEC. Information technology — Dynamic adaptive streaming over HTTP (DASH) — Part 1: Media presentation description and segment formats: ISO/IEC 23009-1:2022(E)[S/OL]. International Organization for Standardization, 2022. https://www.iso.org/standard/83314.html.
1993+
```
1994+
// 注:https://ctan.org/pkg/gbt7714 (bibtex) 和 https://www.ctan.org/pkg/biblatex-gb7714-2015 (biblatex) 要求的`*.bib`格式不同。以上采用前者;后者要求把标准号加到`title`里。
1995+
1996+
=== #bbl(
1997+
en: [Whitespaces and zeros before numbers are trimmed unexpectedly],
1998+
zh: [数字之前的空格和零被意外删除],
1999+
) <bib-num-trim-before>
2000+
2001+
#level.advanced
2002+
#issue("hayagriva#440")
2003+
2004+
```example-bib
2005+
key:
2006+
type: report
2007+
serial-number: GB/X 03792
2008+
# GB/X 03792
19412009
```
19422010

19432011
=== #bbl(en: [Failed to load some CSL styles], zh: [无法加载某些 CSL 样式]) <csl-load>

src/show-example.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
.dark .example > .preview {
4444
background: darkgray;
4545

46-
> svg.typst-frame {
46+
> svg.typst-frame, img {
4747
background: lightgray;
4848
}
4949
}

typ/show-example.typ

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,11 @@
174174
show raw.where(lang: "example-bib"): it => {
175175
let lines = it.text.split("\n")
176176

177-
let displayed = lines.filter(x => not x.starts-with("%")).join("\n")
178-
let expected = lines.filter(x => x.starts-with("%")).map(x => x.trim("%", at: start).trim())
177+
let lang = if it.text.trim().starts-with("@") { "bib" } else { "yaml" }
178+
let comment = if lang == "bib" { "%" } else { "#" }
179+
180+
let displayed = lines.filter(x => not x.starts-with(comment)).join("\n")
181+
let expected = lines.filter(x => x.starts-with(comment)).map(x => x.trim(comment, at: start).trim())
179182

180183
let executed = ````typ
181184
// Some browsers hide the border. Therefore, the margin is necessary.
@@ -185,7 +188,9 @@
185188
Current:
186189
187190
#bibliography(
188-
bytes(```{displayed}```.text),
191+
bytes(```{lang}
192+
{displayed}
193+
```.text),
189194
style: "gb-7714-2015-numeric",
190195
title: none,
191196
full: true,
@@ -198,6 +203,7 @@
198203
````
199204
.text
200205
.replace("{GENERAL-PREAMBLE}", GENERAL-PREAMBLE)
206+
.replace("{lang}", lang) // `lang` is unnecessary here, but helps debugging
201207
.replace("{displayed}", displayed)
202208
.replace("{expected}", expected.map(x => "+ " + x).join("\n"))
203209

@@ -206,7 +212,7 @@
206212
#metadata((id: id, content: executed)) <external-example>
207213
]
208214
show: fix-scaling
209-
layout-external-example(raw(displayed, block: true, lang: "bib"), id)
215+
layout-external-example(raw(displayed, block: true, lang: lang), id)
210216
}
211217

212218
body

0 commit comments

Comments
 (0)