main
1#import "/src/contents/_lib/lib.typ": *
2#show: tybios.post-template
3
4#metadata(
5 (
6 title: "Typst Syntax",
7 desc: "Showing what you can do with Typst in Tybios.",
8 date: datetime(
9 year: 2025,
10 month: 3,
11 day: 12,
12 ),
13 ),
14)<frontmatter>
15
16#tybios.marginnote(block: true)[#outline()]
17
18This is not a reference to Typst syntax, see #link("https://typst.app/docs/reference/")[Typst Reference] for that.
19This is a demonstration of what you can do with Typst syntax in Tybios.
20
21= Basic Text
22
23This is a normal text. You can make it _italic_ or *bold*. You can also make it _*both*_.
24And #underline[underlined], #strike[strikethrough], #overline[overlined] are also supported.
25Why not #highlight[make it highlighted]?
26
27Left a blank line to start a new paragraph.\
28Insert `\` to break a line without starting a new paragraph.
29
30Some characters need to be escaped, such as \#, \*, \_, \`, \\,
31as they are #link("https://typst.app/docs/reference/syntax/#markup")[markup] characters.
32
33Unfortunately, you can't change the font family, size and color inside Typst,
34they are determined by CSS in Tybios.
35
36= Links<heading:links>
37
38Links can be created using the ```typ #link(target, content)```#footnote[
39 Or ```typ #link(target)[content]```, this is a syntactic sugar
40 for the special case of first form: ```typ #link(target, [content])```.
41] function.
42The first argument is the URL, and the second argument is the text to display.
43
44Target can be a URL, like #link("https://codeberg.org/HPCesia/Tybios")[source of Tybios]
45or #link("/Tybios/")[home page]. Typst label an be also a target,
46like #link(label("figure:sine-diagram"))[the sine diagram figure] or #link(label("heading:links"))[this section].
47
48See more imformation about links in #link("https://typst.app/docs/reference/model/link/")[Typst Reference: link].
49
50= Blockquotes
51
52Use ```typ #quote(block: true, attribution: "Author Name")[Content]``` to create a blockquote with attribution.
53
54#quote(block: true, attribution: [Robert A. Heinlein])[
55 A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyse a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.
56]
57
58= Raw Blocks
59
60This is an inline raw block `println!("Hello, world!");`.
61
62This is an inline syntax-highlighted raw block ```rust println!("Hello, world!");```.
63
64This is a long inline raw block
65```css @media(prefers-color-scheme:dark){:root{background-color:var(--color-neutral-900);color:var(--color-neutral-300)}}```.
66
67Js syntax highlight are handled by syntect:
68
69```js
70class T {
71 constructor() {
72 console.log("Hello, world!");
73 }
74}
75```
76
77Typst syntax hightlight are specially handled internally:
78
79```typ
80#let fn(x) = x
81```
82
83= Equations
84
85This is an inline equation $E = m c^2$.
86
87This is a display equation:
88$
89 integral_(0)^(+infinity) (ln x) / (x^2 - 1) dif x = 1/2integral_(x > 0) integral_(y>0) (dif x dif y) / ((1+y)(1+x^2 y)) = pi^2 / 4.
90$
91
92= Tables
93
94Create a table using the ```typ #table()``` function. See more information about tables in #link("https://typst.app/docs/reference/model/table/")[Typst Reference: Table Function].
95
96#figure(
97 table(
98 columns: 4,
99 table.header([Framework], [Language], [License], [Description]),
100 [Astro], [TypeScript], [MIT], [The web framework for content-driven websites.],
101 [Eleventy], [JavaScript], [MIT], [A simpler site generator.],
102 [Hugo], [Go], [Apache-2.0], [The world’s fastest framework for building websites.],
103 [Zola], [Rust], [MIT / EUPL-1.2], [A static site generator in a single binary with everything built-in.],
104 ),
105 caption: [Comparison of static site generators],
106)
107
108Prefer to Markdown tables? A Typst package #link("https://typst.app/universe/package/tablem")[tablem] can help you with that.
109
110#{
111 import "@preview/tablem:0.3.0": tablem
112 tablem[
113 | Name | Location | Height | Score |
114 | ----- | ---------- | ------ | ----- |
115 | John | Second St. | 180 cm | 5 |
116 | Wally | Third Av. | 160 cm | 10 |
117 ]
118}
119
120= Figures
121
122Use ```typ #tybios.frame()``` to wrap any content that can't automatically convert to HTML, convert them to SVGs. #footnote[
123 Converted SVGs will adapt to dark theme by color invert and hue rotation, but the result may not be perfect.
124]
125
126#figure(
127 {
128 import "@preview/lilaq:0.5.0" as lq
129 let x = lq.linspace(0, 10)
130
131 tybios.frame(lq.diagram(
132 lq.plot(x, x => calc.sin(x)),
133 ))
134 },
135 caption: [The diagram of the sine function],
136)<figure:sine-diagram>
137
138= Lists
139
140- An unordered list here
141- You can use `-` to start a unordered list item.
142
143+ An ordered list here
144+ You can use `+` to start a ordered list item, and the number will be automatically generated.
1456. You can also use numbers to specify the order.
146+ After a specified order item, the next item will continue the order you specified.
147
148/ Term: A word or expression that has a precise meaning in some uses or is peculiar to a science, art, profession, or subject. Here is a list of terms.
149/ SVG: #[*S*]calable #[*V*]ector #[*G*]raphics, an XML-based markup language for describing two-dimensional based vector graphics.
150/ XML: E#[*X*]tensible #[*M*]arkup #[*L*]anguage, a strict serialization of the DOM.
151/ DOM: #[*D*]ocument #[*O*]bject #[*M*]odel, connects web pages to scripts or programming languages by representing the structure of a document.
152/ HTML: #[*H*]yper#[*T*]ext #[*M*]arkup #[*L*]anguage, a standard for structuring web content.
153/ URL: #[*U*]niform #[*R*]esource #[*L*]ocator, a text string that specifies where a resource can be found on the Internet.