mirror of
https://github.com/typst/typst
synced 2025-05-14 17:15:28 +08:00
Hashtag -> Hash
This commit is contained in:
parent
7b61d722dd
commit
f474639ebe
@ -64,7 +64,7 @@ Let's dissect what's going on:
|
|||||||
select a particular symbol variant.
|
select a particular symbol variant.
|
||||||
|
|
||||||
- Now, we get to some [scripting]. To input code into a Typst document, we can
|
- Now, we get to some [scripting]. To input code into a Typst document, we can
|
||||||
write a hashtag followed by an expression. We define two variables and a
|
write a hash followed by an expression. We define two variables and a
|
||||||
recursive function to compute the n-th fibonacci number. Then, we display the
|
recursive function to compute the n-th fibonacci number. Then, we display the
|
||||||
results in a center-aligned table. The table function takes its cells
|
results in a center-aligned table. The table function takes its cells
|
||||||
row-by-row. Therefore, we first pass the formulas `$F_1$` to `$F_8$` and then
|
row-by-row. Therefore, we first pass the formulas `$F_1$` to `$F_8$` and then
|
||||||
|
@ -97,7 +97,7 @@ fn complete_markup(ctx: &mut CompletionContext) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start of an interpolated identifier: "#|".
|
// Start of an interpolated identifier: "#|".
|
||||||
if ctx.leaf.kind() == SyntaxKind::Hashtag {
|
if ctx.leaf.kind() == SyntaxKind::Hash {
|
||||||
ctx.from = ctx.cursor;
|
ctx.from = ctx.cursor;
|
||||||
code_completions(ctx, true);
|
code_completions(ctx, true);
|
||||||
return true;
|
return true;
|
||||||
@ -268,7 +268,7 @@ fn complete_math(ctx: &mut CompletionContext) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start of an interpolated identifier: "#|".
|
// Start of an interpolated identifier: "#|".
|
||||||
if ctx.leaf.kind() == SyntaxKind::Hashtag {
|
if ctx.leaf.kind() == SyntaxKind::Hash {
|
||||||
ctx.from = ctx.cursor;
|
ctx.from = ctx.cursor;
|
||||||
code_completions(ctx, true);
|
code_completions(ctx, true);
|
||||||
return true;
|
return true;
|
||||||
@ -326,7 +326,7 @@ fn complete_field_accesses(ctx: &mut CompletionContext) -> bool {
|
|||||||
if let Some(prev) = ctx.leaf.prev_sibling();
|
if let Some(prev) = ctx.leaf.prev_sibling();
|
||||||
if prev.is::<ast::Expr>();
|
if prev.is::<ast::Expr>();
|
||||||
if prev.parent_kind() != Some(SyntaxKind::Markup) ||
|
if prev.parent_kind() != Some(SyntaxKind::Markup) ||
|
||||||
prev.prev_sibling_kind() == Some(SyntaxKind::Hashtag);
|
prev.prev_sibling_kind() == Some(SyntaxKind::Hash);
|
||||||
if let Some(value) = analyze_expr(ctx.world, &prev).into_iter().next();
|
if let Some(value) = analyze_expr(ctx.world, &prev).into_iter().next();
|
||||||
then {
|
then {
|
||||||
ctx.from = ctx.cursor;
|
ctx.from = ctx.cursor;
|
||||||
@ -796,8 +796,8 @@ fn complete_code(ctx: &mut CompletionContext) -> bool {
|
|||||||
|
|
||||||
/// Add completions for expression snippets.
|
/// Add completions for expression snippets.
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
fn code_completions(ctx: &mut CompletionContext, hashtag: bool) {
|
fn code_completions(ctx: &mut CompletionContext, hash: bool) {
|
||||||
ctx.scope_completions(true, |value| !hashtag || {
|
ctx.scope_completions(true, |value| !hash || {
|
||||||
matches!(value, Value::Symbol(_) | Value::Func(_) | Value::Type(_) | Value::Module(_))
|
matches!(value, Value::Symbol(_) | Value::Func(_) | Value::Type(_) | Value::Module(_))
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -933,7 +933,7 @@ fn code_completions(ctx: &mut CompletionContext, hashtag: bool) {
|
|||||||
"Creates a mapping from names to value.",
|
"Creates a mapping from names to value.",
|
||||||
);
|
);
|
||||||
|
|
||||||
if !hashtag {
|
if !hash {
|
||||||
ctx.snippet_completion(
|
ctx.snippet_completion(
|
||||||
"function",
|
"function",
|
||||||
"(${params}) => ${output}",
|
"(${params}) => ${output}",
|
||||||
|
@ -49,7 +49,7 @@ fn expr_tooltip(world: &dyn World, leaf: &LinkedNode) -> Option<Tooltip> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let expr = ancestor.cast::<ast::Expr>()?;
|
let expr = ancestor.cast::<ast::Expr>()?;
|
||||||
if !expr.hashtag() && !matches!(expr, ast::Expr::MathIdent(_)) {
|
if !expr.hash() && !matches!(expr, ast::Expr::MathIdent(_)) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,8 +339,8 @@ impl<'a> AstNode<'a> for Expr<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Expr<'_> {
|
impl Expr<'_> {
|
||||||
/// Can this expression be embedded into markup with a hashtag?
|
/// Can this expression be embedded into markup with a hash?
|
||||||
pub fn hashtag(self) -> bool {
|
pub fn hash(self) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
self,
|
self,
|
||||||
Self::Ident(_)
|
Self::Ident(_)
|
||||||
|
@ -174,7 +174,7 @@ pub fn highlight(node: &LinkedNode) -> Option<Tag> {
|
|||||||
SyntaxKind::MathRoot => None,
|
SyntaxKind::MathRoot => None,
|
||||||
SyntaxKind::MathPrimes => None,
|
SyntaxKind::MathPrimes => None,
|
||||||
|
|
||||||
SyntaxKind::Hashtag => highlight_hashtag(node),
|
SyntaxKind::Hash => highlight_hash(node),
|
||||||
SyntaxKind::LeftBrace => Some(Tag::Punctuation),
|
SyntaxKind::LeftBrace => Some(Tag::Punctuation),
|
||||||
SyntaxKind::RightBrace => Some(Tag::Punctuation),
|
SyntaxKind::RightBrace => Some(Tag::Punctuation),
|
||||||
SyntaxKind::LeftBracket => Some(Tag::Punctuation),
|
SyntaxKind::LeftBracket => Some(Tag::Punctuation),
|
||||||
@ -322,8 +322,8 @@ fn highlight_ident(node: &LinkedNode) -> Option<Tag> {
|
|||||||
return Some(Tag::Function);
|
return Some(Tag::Function);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Are we (or an ancestor field access) directly after a hashtag.
|
// Are we (or an ancestor field access) directly after a hash.
|
||||||
if ancestor.prev_leaf().map(|leaf| leaf.kind()) == Some(SyntaxKind::Hashtag) {
|
if ancestor.prev_leaf().map(|leaf| leaf.kind()) == Some(SyntaxKind::Hash) {
|
||||||
return Some(Tag::Interpolated);
|
return Some(Tag::Interpolated);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,11 +339,11 @@ fn highlight_ident(node: &LinkedNode) -> Option<Tag> {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Highlight a hashtag based on context.
|
/// Highlight a hash based on context.
|
||||||
fn highlight_hashtag(node: &LinkedNode) -> Option<Tag> {
|
fn highlight_hash(node: &LinkedNode) -> Option<Tag> {
|
||||||
let next = node.next_sibling()?;
|
let next = node.next_sibling()?;
|
||||||
let expr = next.cast::<ast::Expr>()?;
|
let expr = next.cast::<ast::Expr>()?;
|
||||||
if !expr.hashtag() {
|
if !expr.hash() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
highlight(&next.leftmost_leaf()?)
|
highlight(&next.leftmost_leaf()?)
|
||||||
|
@ -72,8 +72,8 @@ pub enum SyntaxKind {
|
|||||||
/// A root in math: `√x`, `∛x` or `∜x`.
|
/// A root in math: `√x`, `∛x` or `∜x`.
|
||||||
MathRoot,
|
MathRoot,
|
||||||
|
|
||||||
/// A hashtag that switches into code mode: `#`.
|
/// A hash that switches into code mode: `#`.
|
||||||
Hashtag,
|
Hash,
|
||||||
/// A left curly brace, starting a code block: `{`.
|
/// A left curly brace, starting a code block: `{`.
|
||||||
LeftBrace,
|
LeftBrace,
|
||||||
/// A right curly brace, terminating a code block: `}`.
|
/// A right curly brace, terminating a code block: `}`.
|
||||||
@ -385,7 +385,7 @@ impl SyntaxKind {
|
|||||||
Self::MathFrac => "math fraction",
|
Self::MathFrac => "math fraction",
|
||||||
Self::MathRoot => "math root",
|
Self::MathRoot => "math root",
|
||||||
Self::MathPrimes => "math primes",
|
Self::MathPrimes => "math primes",
|
||||||
Self::Hashtag => "hashtag",
|
Self::Hash => "hash",
|
||||||
Self::LeftBrace => "opening brace",
|
Self::LeftBrace => "opening brace",
|
||||||
Self::RightBrace => "closing brace",
|
Self::RightBrace => "closing brace",
|
||||||
Self::LeftBracket => "opening bracket",
|
Self::LeftBracket => "opening bracket",
|
||||||
|
@ -175,7 +175,7 @@ impl Lexer<'_> {
|
|||||||
'*' if !self.in_word() => SyntaxKind::Star,
|
'*' if !self.in_word() => SyntaxKind::Star,
|
||||||
'_' if !self.in_word() => SyntaxKind::Underscore,
|
'_' if !self.in_word() => SyntaxKind::Underscore,
|
||||||
|
|
||||||
'#' => SyntaxKind::Hashtag,
|
'#' => SyntaxKind::Hash,
|
||||||
'[' => SyntaxKind::LeftBracket,
|
'[' => SyntaxKind::LeftBracket,
|
||||||
']' => SyntaxKind::RightBracket,
|
']' => SyntaxKind::RightBracket,
|
||||||
'\'' => SyntaxKind::SmartQuote,
|
'\'' => SyntaxKind::SmartQuote,
|
||||||
@ -425,7 +425,7 @@ impl Lexer<'_> {
|
|||||||
'~' if self.s.eat_if('>') => SyntaxKind::Shorthand,
|
'~' if self.s.eat_if('>') => SyntaxKind::Shorthand,
|
||||||
'*' | '-' => SyntaxKind::Shorthand,
|
'*' | '-' => SyntaxKind::Shorthand,
|
||||||
|
|
||||||
'#' => SyntaxKind::Hashtag,
|
'#' => SyntaxKind::Hash,
|
||||||
'_' => SyntaxKind::Underscore,
|
'_' => SyntaxKind::Underscore,
|
||||||
'$' => SyntaxKind::Dollar,
|
'$' => SyntaxKind::Dollar,
|
||||||
'/' => SyntaxKind::Slash,
|
'/' => SyntaxKind::Slash,
|
||||||
|
@ -117,7 +117,7 @@ fn markup_expr(p: &mut Parser, at_start: &mut bool) {
|
|||||||
| SyntaxKind::Link
|
| SyntaxKind::Link
|
||||||
| SyntaxKind::Label => p.eat(),
|
| SyntaxKind::Label => p.eat(),
|
||||||
|
|
||||||
SyntaxKind::Hashtag => embedded_code_expr(p),
|
SyntaxKind::Hash => embedded_code_expr(p),
|
||||||
SyntaxKind::Star => strong(p),
|
SyntaxKind::Star => strong(p),
|
||||||
SyntaxKind::Underscore => emph(p),
|
SyntaxKind::Underscore => emph(p),
|
||||||
SyntaxKind::HeadingMarker if *at_start => heading(p),
|
SyntaxKind::HeadingMarker if *at_start => heading(p),
|
||||||
@ -254,7 +254,7 @@ fn math_expr_prec(p: &mut Parser, min_prec: usize, stop: SyntaxKind) {
|
|||||||
let m = p.marker();
|
let m = p.marker();
|
||||||
let mut continuable = false;
|
let mut continuable = false;
|
||||||
match p.current() {
|
match p.current() {
|
||||||
SyntaxKind::Hashtag => embedded_code_expr(p),
|
SyntaxKind::Hash => embedded_code_expr(p),
|
||||||
SyntaxKind::MathIdent => {
|
SyntaxKind::MathIdent => {
|
||||||
continuable = true;
|
continuable = true;
|
||||||
p.eat();
|
p.eat();
|
||||||
@ -595,7 +595,7 @@ fn code_expr_or_pattern(p: &mut Parser) {
|
|||||||
fn embedded_code_expr(p: &mut Parser) {
|
fn embedded_code_expr(p: &mut Parser) {
|
||||||
p.enter_newline_mode(NewlineMode::Stop);
|
p.enter_newline_mode(NewlineMode::Stop);
|
||||||
p.enter(LexMode::Code);
|
p.enter(LexMode::Code);
|
||||||
p.assert(SyntaxKind::Hashtag);
|
p.assert(SyntaxKind::Hash);
|
||||||
p.unskip();
|
p.unskip();
|
||||||
|
|
||||||
let stmt = matches!(
|
let stmt = matches!(
|
||||||
|
@ -125,8 +125,8 @@ fn try_reparse(
|
|||||||
end += 1;
|
end += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Also take hashtag.
|
// Also take hash.
|
||||||
if start > 0 && children[start - 1].kind() == SyntaxKind::Hashtag {
|
if start > 0 && children[start - 1].kind() == SyntaxKind::Hash {
|
||||||
start -= 1;
|
start -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +223,7 @@ pub fn eval_string(
|
|||||||
/// In which mode to evaluate a string.
|
/// In which mode to evaluate a string.
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash, Cast)]
|
||||||
pub enum EvalMode {
|
pub enum EvalMode {
|
||||||
/// Evaluate as code, as after a hashtag.
|
/// Evaluate as code, as after a hash.
|
||||||
Code,
|
Code,
|
||||||
/// Evaluate as markup, like in a Typst file.
|
/// Evaluate as markup, like in a Typst file.
|
||||||
Markup,
|
Markup,
|
||||||
|
@ -453,7 +453,7 @@ impl Color {
|
|||||||
/// The color in hexadecimal notation.
|
/// The color in hexadecimal notation.
|
||||||
///
|
///
|
||||||
/// Accepts three, four, six or eight hexadecimal digits and optionally
|
/// Accepts three, four, six or eight hexadecimal digits and optionally
|
||||||
/// a leading hashtag.
|
/// a leading hash.
|
||||||
///
|
///
|
||||||
/// If this string is given, the individual components should not be given.
|
/// If this string is given, the individual components should not be given.
|
||||||
///
|
///
|
||||||
@ -1361,11 +1361,11 @@ impl FromStr for Color {
|
|||||||
type Err = &'static str;
|
type Err = &'static str;
|
||||||
|
|
||||||
/// Constructs a new color from hex strings like the following:
|
/// Constructs a new color from hex strings like the following:
|
||||||
/// - `#aef` (shorthand, with leading hashtag),
|
/// - `#aef` (shorthand, with leading hash),
|
||||||
/// - `7a03c2` (without alpha),
|
/// - `7a03c2` (without alpha),
|
||||||
/// - `abcdefff` (with alpha).
|
/// - `abcdefff` (with alpha).
|
||||||
///
|
///
|
||||||
/// The hashtag is optional and both lower and upper case are fine.
|
/// The hash is optional and both lower and upper case are fine.
|
||||||
fn from_str(hex_str: &str) -> Result<Self, Self::Err> {
|
fn from_str(hex_str: &str) -> Result<Self, Self::Err> {
|
||||||
let hex_str = hex_str.strip_prefix('#').unwrap_or(hex_str);
|
let hex_str = hex_str.strip_prefix('#').unwrap_or(hex_str);
|
||||||
if hex_str.chars().any(|c| !c.is_ascii_hexdigit()) {
|
if hex_str.chars().any(|c| !c.is_ascii_hexdigit()) {
|
||||||
|
@ -888,8 +888,8 @@ description: |
|
|||||||
[Go to the announcement blog post.](https://typst.app/blog/2023/january-update)
|
[Go to the announcement blog post.](https://typst.app/blog/2023/january-update)
|
||||||
- New expression syntax in markup/math
|
- New expression syntax in markup/math
|
||||||
- Blocks cannot be directly embedded in markup anymore
|
- Blocks cannot be directly embedded in markup anymore
|
||||||
- Like other expressions, they now require a leading hashtag
|
- Like other expressions, they now require a leading hash
|
||||||
- More expressions available with hashtag, including literals (`[#"string"]`)
|
- More expressions available with hash, including literals (`[#"string"]`)
|
||||||
as well as field access and method call without space: `[#emoji.face]`
|
as well as field access and method call without space: `[#emoji.face]`
|
||||||
- New import syntax
|
- New import syntax
|
||||||
- `[#import "module.typ"]` creates binding named `module`
|
- `[#import "module.typ"]` creates binding named `module`
|
||||||
@ -906,7 +906,7 @@ description: |
|
|||||||
- Symbols now listed in documentation
|
- Symbols now listed in documentation
|
||||||
- New `{math}` module
|
- New `{math}` module
|
||||||
- Contains all math-related functions
|
- Contains all math-related functions
|
||||||
- Variables and function calls directly in math (without hashtag) access this
|
- Variables and function calls directly in math (without hash) access this
|
||||||
module instead of the global scope, but can also access local variables
|
module instead of the global scope, but can also access local variables
|
||||||
- Can be explicitly used in code, e.g. `[#set math.vec(delim: "[")]`
|
- Can be explicitly used in code, e.g. `[#set math.vec(delim: "[")]`
|
||||||
- Delimiter matching in math
|
- Delimiter matching in math
|
||||||
@ -924,7 +924,7 @@ description: |
|
|||||||
- Alignment points also work for underbraces, vectors, cases, and matrices
|
- Alignment points also work for underbraces, vectors, cases, and matrices
|
||||||
- Multiple alignment points are supported
|
- Multiple alignment points are supported
|
||||||
- More capable math function calls
|
- More capable math function calls
|
||||||
- Function calls directly in math can now take code expressions with hashtag
|
- Function calls directly in math can now take code expressions with hash
|
||||||
- They can now also take named arguments
|
- They can now also take named arguments
|
||||||
- Within math function calls, semicolons turn preceding arguments to arrays to
|
- Within math function calls, semicolons turn preceding arguments to arrays to
|
||||||
support matrices: `[$mat(1, 2; 3, 4)$]`
|
support matrices: `[$mat(1, 2; 3, 4)$]`
|
||||||
|
@ -119,8 +119,8 @@ parallels programming languages like Python, providing the option to input and
|
|||||||
execute segments of code.
|
execute segments of code.
|
||||||
|
|
||||||
Within Typst's markup, you can switch to code mode for a single command (or
|
Within Typst's markup, you can switch to code mode for a single command (or
|
||||||
rather, _expression_) using a hashtag (`#`). This is how you call functions to,
|
rather, _expression_) using a hash (`#`). This is how you call functions to, for
|
||||||
for example, split your project into different [files]($scripting/#modules) or
|
example, split your project into different [files]($scripting/#modules) or
|
||||||
render text based on some [condition]($scripting/#conditionals). Within code
|
render text based on some [condition]($scripting/#conditionals). Within code
|
||||||
mode, it is possible to include normal markup [_content_]($content) by using
|
mode, it is possible to include normal markup [_content_]($content) by using
|
||||||
square brackets. Within code mode, this content is treated just as any other
|
square brackets. Within code mode, this content is treated just as any other
|
||||||
|
@ -20,7 +20,7 @@ math: |
|
|||||||
In math, single letters are always displayed as is. Multiple letters, however,
|
In math, single letters are always displayed as is. Multiple letters, however,
|
||||||
are interpreted as variables and functions. To display multiple letters
|
are interpreted as variables and functions. To display multiple letters
|
||||||
verbatim, you can place them into quotes and to access single letter
|
verbatim, you can place them into quotes and to access single letter
|
||||||
variables, you can use the [hashtag syntax]($scripting/#expressions).
|
variables, you can use the [hash syntax]($scripting/#expressions).
|
||||||
|
|
||||||
```example
|
```example
|
||||||
$ A = pi r^2 $
|
$ A = pi r^2 $
|
||||||
@ -51,11 +51,11 @@ math: |
|
|||||||
&= (n(n+1)) / 2 $
|
&= (n(n+1)) / 2 $
|
||||||
```
|
```
|
||||||
|
|
||||||
Math mode supports special function calls without the hashtag prefix. In these
|
Math mode supports special function calls without the hash prefix. In these
|
||||||
"math calls", the argument list works a little differently than in code:
|
"math calls", the argument list works a little differently than in code:
|
||||||
|
|
||||||
- Within them, Typst is still in "math mode". Thus, you can write math
|
- Within them, Typst is still in "math mode". Thus, you can write math
|
||||||
directly into them, but need to use hashtag syntax to pass code expressions
|
directly into them, but need to use hash syntax to pass code expressions
|
||||||
(except for strings, which are available in the math syntax).
|
(except for strings, which are available in the math syntax).
|
||||||
- They support positional and named arguments, but don't support trailing
|
- They support positional and named arguments, but don't support trailing
|
||||||
content blocks and argument spreading.
|
content blocks and argument spreading.
|
||||||
@ -76,7 +76,7 @@ math: |
|
|||||||
directly preceded by an identifier, so to display it verbatim in those cases,
|
directly preceded by an identifier, so to display it verbatim in those cases,
|
||||||
you can just insert a space before it.
|
you can just insert a space before it.
|
||||||
|
|
||||||
Functions calls preceded by a hashtag are normal code function calls and not
|
Functions calls preceded by a hash are normal code function calls and not
|
||||||
affected by these rules.
|
affected by these rules.
|
||||||
|
|
||||||
All math functions are part of the `math` [module]($scripting/#modules), which
|
All math functions are part of the `math` [module]($scripting/#modules), which
|
||||||
|
@ -11,7 +11,7 @@ scripting concepts.
|
|||||||
In Typst, markup and code are fused into one. All but the most common elements
|
In Typst, markup and code are fused into one. All but the most common elements
|
||||||
are created with _functions._ To make this as convenient as possible, Typst
|
are created with _functions._ To make this as convenient as possible, Typst
|
||||||
provides compact syntax to embed a code expression into markup: An expression is
|
provides compact syntax to embed a code expression into markup: An expression is
|
||||||
introduced with a hashtag (`#`) and normal markup parsing resumes after the
|
introduced with a hash (`#`) and normal markup parsing resumes after the
|
||||||
expression is finished. If a character would continue the expression but should
|
expression is finished. If a character would continue the expression but should
|
||||||
be interpreted as text, the expression can forcibly be ended with a semicolon
|
be interpreted as text, the expression can forcibly be ended with a semicolon
|
||||||
(`;`).
|
(`;`).
|
||||||
@ -26,7 +26,7 @@ The example above shows a few of the available expressions, including
|
|||||||
[function calls]($function), [field accesses]($scripting/#fields), and
|
[function calls]($function), [field accesses]($scripting/#fields), and
|
||||||
[method calls]($scripting/#methods). More kinds of expressions are
|
[method calls]($scripting/#methods). More kinds of expressions are
|
||||||
discussed in the remainder of this chapter. A few kinds of expressions are not
|
discussed in the remainder of this chapter. A few kinds of expressions are not
|
||||||
compatible with the hashtag syntax (e.g. binary operator expressions). To embed
|
compatible with the hash syntax (e.g. binary operator expressions). To embed
|
||||||
these into markup, you can use parentheses, as in `[#(1 + 2)]`.
|
these into markup, you can use parentheses, as in `[#(1 + 2)]`.
|
||||||
|
|
||||||
## Blocks
|
## Blocks
|
||||||
|
@ -120,8 +120,10 @@ default. It's also lacking a caption. Let's fix that by using the
|
|||||||
[figure]($figure) function. This function takes the figure's contents as a
|
[figure]($figure) function. This function takes the figure's contents as a
|
||||||
positional argument and an optional caption as a named argument.
|
positional argument and an optional caption as a named argument.
|
||||||
|
|
||||||
Within the argument list of the `figure` function, Typst is already in code mode. This means, you can now remove the hashtag before the image function call.
|
Within the argument list of the `figure` function, Typst is already in code
|
||||||
The hashtag is only needed directly in markup (to disambiguate text from function calls).
|
mode. This means, you can now remove the hash before the image function call.
|
||||||
|
The hash is only needed directly in markup (to disambiguate text from function
|
||||||
|
calls).
|
||||||
|
|
||||||
The caption consists of arbitrary markup. To give markup to a function, we
|
The caption consists of arbitrary markup. To give markup to a function, we
|
||||||
enclose it in square brackets. This construct is called a _content block._
|
enclose it in square brackets. This construct is called a _content block._
|
||||||
|
Loading…
x
Reference in New Issue
Block a user