mirror of
https://github.com/typst/typst
synced 2025-05-14 04:56:26 +08:00
This adds overridable functions that markup desugars into. Specifically: - \ desugars into linebreak - Two newlines desugar into parbreak - * desugars into strong - _ desugars into emph - = .. desugars into heading - `..` desugars into raw
53 lines
787 B
Typst
53 lines
787 B
Typst
// Test headings.
|
|
|
|
---
|
|
// Different number of hashtags.
|
|
|
|
// Valid levels.
|
|
=1
|
|
===2
|
|
======6
|
|
|
|
// Too many hashtags.
|
|
// Warning: 1-8 should not exceed depth 6
|
|
=======7
|
|
|
|
---
|
|
// Heading continuation over linebreak.
|
|
|
|
// Code blocks continue heading.
|
|
= A{
|
|
"B"
|
|
}
|
|
|
|
// Function call continues heading.
|
|
= #rect[
|
|
A
|
|
] B
|
|
|
|
// Without some kind of block, headings end at a line break.
|
|
= A
|
|
B
|
|
|
|
---
|
|
// Heading vs. no heading.
|
|
|
|
// Parsed as headings if at start of the context.
|
|
/**/ = Ok
|
|
{[== Ok]}
|
|
#rect[=== Ok]
|
|
|
|
// Not at the start of the context.
|
|
No = heading
|
|
|
|
// Escaped.
|
|
\= No heading
|
|
|
|
---
|
|
// Make small, but double heading.
|
|
#let heading(contents) = heading(contents + contents, level: 6)
|
|
|
|
// The new heading's argument list doesn't contain `level`.
|
|
// Error: 1-11 unexpected argument
|
|
=== Twice.
|