Skip to content

Commit b149842

Browse files
dev: update module examples
1 parent f3381b2 commit b149842

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/intermediate/modulize-modules.typ

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
#show: book.page.with(title: [文件与模块])
44

5+
#set page(height: auto)
6+
57
正如我们在《初识脚本模式》中所说的,Typst提供了脚本语言方便排版。但事实上,写作时若能少写甚至不写脚本,这才算真正的便捷。我们总希望Typst能够允许我们以一种优雅的方式#strike[复制粘贴]引入已有代码。理想情况下,只需两行代码便可引入前辈写好的模板:
68

79
#```typ
@@ -52,22 +54,22 @@ typst c --root / # Linux或macOS
5254

5355
我们已经讲解过`read`函数和`include`语法,其中都有路径的概念。
5456

55-
如果路径以字符`/`开头,则其为「绝对路径」。绝对路径相对于「根目录」解析。若设置了根目录为#text(red, `/OwO/`),则路径`/a/b/c`对应路径#text(red, `/OwO/`)`a/b/c`
57+
如果路径以字符`/`开头,则其为「绝对路径」。绝对路径相对于「根目录」解析。若设置了根目录为#text(red, `/OwO/`),则路径`/src/chapter1.typ`对应文件系统中的#text(red, `/OwO/`)`src/chapter1.typ`
5658

5759
#code(
5860
```typ
59-
#include "/src/intermediate/chapter1.typ"
61+
#include "/src/chapter1.typ"
6062
```,
61-
res: [我是`/OwO/src/intermediate/chapter1.typ`文件!],
63+
res: [我是#text(red, `/OwO/`)`src/chapter1.typ`文件!],
6264
)
6365

64-
否则,路径不以字符`/`开头,则其「相对路径」。相对路径相对于当前文件的父文件夹解析。若我们正在编辑#text(red, `/OwO/src/intermediate/`)`main.typ`文件,则路径`d/e/f`对应路径#text(red, `/OwO/src/intermediate/`)`d/e/f`
66+
否则,路径不以字符`/`开头,则其「相对路径」。相对路径相对于当前文件的父文件夹解析。若我们正在编辑#text(red, `/OwO/`)#text(blue, `src/`)`main.typ`文件,则路径`chapter2.typ`对应文件系统中的#text(red, `/OwO/`)#text(blue, `src/`)`chapter2.typ`
6567

6668
#code(
6769
```typ
6870
#include "chapter2.typ"
6971
```,
70-
res: [我是`/OwO/src/intermediate/chapter2.typ`文件!],
72+
res: [我是#text(red, `/OwO/`)#text(blue, `src/`)`chapter2.typ`文件!],
7173
)
7274

7375
== 「import」语法与「模块」

0 commit comments

Comments
 (0)