Skip to content

Commit 1e11cf1

Browse files
feat: 一些样式 (#14)
1 parent d050e6e commit 1e11cf1

File tree

3 files changed

+56
-24
lines changed

3 files changed

+56
-24
lines changed

src/basic/mod.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import "/src/book.typ"
2-
#import "/typ/templates/page.typ": main-color
2+
#import "/typ/templates/page.typ": main-color, is-web-target
33

44
#import "../mod.typ": (
55
code as _code,

src/basic/writing-markup.typ

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,23 @@ Typst希望你总是尽可能少的配置样式,就获得一个排版精良的
9292

9393
例如在英文排版中,#typst-func("strong")的样式是加粗,#typst-func("emph")的样式是倾斜。你完全可以在中文排版中为它们更换样式。
9494

95-
#code(```typ
96-
#show strong: content => {
97-
show regex("\p{Hani}"): it => box(place(text("·", size: 1.3em), dx: 0.3em, dy: 0.5em) + it)
98-
content.body
95+
#if is-web-target {
96+
code(```typ
97+
#show strong: content => {
98+
show regex("\p{Hani}"): it => box(place(text("·", size: 0.8em), dx: 0.1em, dy: 0.75em) + it)
99+
content.body
100+
}
101+
*中文排版的着重语义用加点表示。*
102+
```)
103+
} else {
104+
code(```typ
105+
#show strong: content => {
106+
show regex("\p{Hani}"): it => box(place(text("·", size: 1.3em), dx: 0.3em, dy: 0.5em) + it)
107+
content.body
108+
}
109+
*中文排版的着重语义用加点表示。*
110+
```)
99111
}
100-
*中文排版的着重语义用加点表示。*
101-
```)
102112
]
103113

104114
与许多标记语言相同,Typst中使用一系列#term("delimiter")规则确定一段语义的开始和结束。为赋予语义,需要将一个#term("delimiter")置于文本*之前*,表示某语义的开始;同时将另一个#term("delimiter")置于文本*之后*,表示该语义的结束。
@@ -400,7 +410,7 @@ Typst的#term("comment")直接采用C语言风格的注释语法,有两种表
400410

401411
== 总结
402412

403-
基于《编写一篇基本文档》前半部分掌握的知识,你应该编写一些非常简单的文档。
413+
基于《初识标记模式》掌握的知识,你应该编写一些非常简单的文档。
404414

405415
== 习题
406416

src/figures.typ

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#import "@preview/fletcher:0.5.4" as fletcher: node, edge
2-
#import "/typ/templates/page.typ": main-color, is-light-theme
2+
#import "/typ/templates/page.typ": main-color, is-light-theme, page-width
33
#import "mod.typ": typst-func
44

55
#let figure-typst-arch(
@@ -29,22 +29,44 @@
2929
#let figure-content-decoration(
3030
stroke-color: main-color,
3131
light-theme: is-light-theme,
32+
width: page-width,
3233
) = {
3334
// let node = node.with(stroke: main-color + 0.5pt)
34-
let xd = align.with(center)
35+
let node-text = align.with(center)
3536

36-
fletcher.diagram(
37-
node-outset: 2pt,
38-
axes: (ltr, btt),
39-
// nodes
40-
node((0, 0), xd[```typ 左#[一段文本]右```]),
41-
node((1.5, 0), xd(```typc text(blue)```)),
42-
node((3, 0), xd([左] + text(blue)[一段文本] + [右])),
43-
node((0, -0.5), xd[选中内容]),
44-
node((1.5, -0.5), xd[对内容块应用#typst-func("text")函数]),
45-
node((3, -0.5), xd[最终效果]),
46-
// edges
47-
edge((0, 0), (1.5, 0), "..}>"),
48-
edge((1.5, 0), (3, 0), "..}>"),
49-
)
37+
// todo: 消除重复
38+
if width < 500pt {
39+
let node-rect-text(content) = rect(node-text(content), width: 125pt)
40+
fletcher.diagram(
41+
node-outset: 2pt,
42+
axes: (ltr, btt),
43+
// nodes
44+
node((0, 0), node-rect-text[```typ 左#[一段文本]右```]),
45+
node((0, -1.5), node-rect-text(```typc text(blue)```)),
46+
node((0, -3), node-rect-text([左] + text(blue)[一段文本] + [右])),
47+
48+
node((0, -0.5 + 0), node-text[选中内容]),
49+
node((0, -0.5 + -1.5), node-text[对内容块应用#typst-func("text")函数]),
50+
node((0, -0.5 + -3), node-text[最终效果]),
51+
52+
// edges
53+
edge((0, -0.5 + 0), (0, -1.5), "..}>"),
54+
edge((0, -0.5 + -1.5), (0, -3), "..}>"),
55+
)
56+
} else {
57+
fletcher.diagram(
58+
node-outset: 2pt,
59+
axes: (ltr, btt),
60+
// nodes
61+
node((0, 0), node-text[```typ 左#[一段文本]右```]),
62+
node((1.5, 0), node-text(```typc text(blue)```)),
63+
node((3, 0), node-text([左] + text(blue)[一段文本] + [右])),
64+
node((0, -0.5), node-text[选中内容]),
65+
node((1.5, -0.5), node-text[对内容块应用#typst-func("text")函数]),
66+
node((3, -0.5), node-text[最终效果]),
67+
// edges
68+
edge((0, 0), (1.5, 0), "..}>"),
69+
edge((1.5, 0), (3, 0), "..}>"),
70+
)
71+
}
5072
}

0 commit comments

Comments
 (0)