Skip to content

Commit

Permalink
dev: 一些样式
Browse files Browse the repository at this point in the history
  • Loading branch information
Myriad-Dreamin committed Jan 15, 2025
1 parent d050e6e commit 168d0f4
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/basic/mod.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "/src/book.typ"
#import "/typ/templates/page.typ": main-color
#import "/typ/templates/page.typ": main-color, is-web-target

#import "../mod.typ": (
code as _code,
Expand Down
24 changes: 17 additions & 7 deletions src/basic/writing-markup.typ
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,23 @@ Typst希望你总是尽可能少的配置样式,就获得一个排版精良的

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

#code(```typ
#show strong: content => {
show regex("\p{Hani}"): it => box(place(text("·", size: 1.3em), dx: 0.3em, dy: 0.5em) + it)
content.body
#if is-web-target {
code(```typ
#show strong: content => {
show regex("\p{Hani}"): it => box(place(text("·", size: 0.8em), dx: 0.1em, dy: 0.75em) + it)
content.body
}
*中文排版的着重语义用加点表示。*
```)
} else {
code(```typ
#show strong: content => {
show regex("\p{Hani}"): it => box(place(text("·", size: 1.3em), dx: 0.3em, dy: 0.5em) + it)
content.body
}
*中文排版的着重语义用加点表示。*
```)
}
*中文排版的着重语义用加点表示。*
```)
]

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

== 总结

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

== 习题

Expand Down
54 changes: 38 additions & 16 deletions src/figures.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "@preview/fletcher:0.5.4" as fletcher: node, edge
#import "/typ/templates/page.typ": main-color, is-light-theme
#import "/typ/templates/page.typ": main-color, is-light-theme, page-width
#import "mod.typ": typst-func

#let figure-typst-arch(
Expand Down Expand Up @@ -29,22 +29,44 @@
#let figure-content-decoration(
stroke-color: main-color,
light-theme: is-light-theme,
width: page-width,
) = {
// let node = node.with(stroke: main-color + 0.5pt)
let xd = align.with(center)
let node-text = align.with(center)

fletcher.diagram(
node-outset: 2pt,
axes: (ltr, btt),
// nodes
node((0, 0), xd[```typ 左#[一段文本]右```]),
node((1.5, 0), xd(```typc text(blue)```)),
node((3, 0), xd([左] + text(blue)[一段文本] + [右])),
node((0, -0.5), xd[选中内容]),
node((1.5, -0.5), xd[对内容块应用#typst-func("text")函数]),
node((3, -0.5), xd[最终效果]),
// edges
edge((0, 0), (1.5, 0), "..}>"),
edge((1.5, 0), (3, 0), "..}>"),
)
// todo: 消除重复
if width < 500pt {
let node-rect-text(content) = rect(node-text(content), width: 125pt)
fletcher.diagram(
node-outset: 2pt,
axes: (ltr, btt),
// nodes
node((0, 0), node-rect-text[```typ 左#[一段文本]右```]),
node((0, -1.5), node-rect-text(```typc text(blue)```)),
node((0, -3), node-rect-text([左] + text(blue)[一段文本] + [右])),

node((0, -0.5 + 0), node-text[选中内容]),
node((0, -0.5 + -1.5), node-text[对内容块应用#typst-func("text")函数]),
node((0, -0.5 + -3), node-text[最终效果]),

// edges
edge((0, -0.5 + 0), (0, -1.5), "..}>"),
edge((0, -0.5 + -1.5), (0, -3), "..}>"),
)
} else {
fletcher.diagram(
node-outset: 2pt,
axes: (ltr, btt),
// nodes
node((0, 0), node-text[```typ 左#[一段文本]右```]),
node((1.5, 0), node-text(```typc text(blue)```)),
node((3, 0), node-text([左] + text(blue)[一段文本] + [右])),
node((0, -0.5), node-text[选中内容]),
node((1.5, -0.5), node-text[对内容块应用#typst-func("text")函数]),
node((3, -0.5), node-text[最终效果]),
// edges
edge((0, 0), (1.5, 0), "..}>"),
edge((1.5, 0), (3, 0), "..}>"),
)
}
}

0 comments on commit 168d0f4

Please sign in to comment.