Fix links

This commit is contained in:
Laurenz 2023-02-14 14:39:19 +01:00
parent b9c0fd87d3
commit 618beb1ac1
4 changed files with 35 additions and 19 deletions

View File

@ -125,15 +125,10 @@ impl<'a> Handler<'a> {
"unsupported link type: {ty:?}", "unsupported link type: {ty:?}",
); );
let mut link = self *dest = self
.handle_link(dest) .handle_link(dest)
.unwrap_or_else(|| panic!("invalid link: {dest}")); .unwrap_or_else(|| panic!("invalid link: {dest}"))
.into();
if !link.contains('#') && !link.ends_with('/') {
link.push('/');
}
*dest = link.into();
} }
// Inline raw. // Inline raw.
@ -226,16 +221,36 @@ impl<'a> Handler<'a> {
let info = func.info()?; let info = func.info()?;
route.push_str(info.category); route.push_str(info.category);
route.push('/'); route.push('/');
route.push_str(name);
route.push('/'); if let Some(group) = GROUPS
if let Some(param) = param { .iter()
route.push_str("#parameters--"); .find(|group| group.functions.iter().any(|func| func == info.name))
route.push_str(param); {
route.push_str(&group.name);
route.push_str("/#");
route.push_str(info.name);
if let Some(param) = param {
route.push_str("-parameters--");
route.push_str(param);
} else {
route.push_str("-summary");
}
} else {
route.push_str(name);
route.push('/');
if let Some(param) = param {
route.push_str("#parameters--");
route.push_str(param);
}
} }
} else { } else {
route.push_str(rest); route.push_str(rest);
} }
if !route.contains('#') && !route.ends_with('/') {
route.push('/');
}
Some(route) Some(route)
} }
} }

View File

@ -209,7 +209,7 @@ fn category_page(resolver: &dyn Resolver, category: &str) -> PageModel {
// Skip grouped functions. // Skip grouped functions.
if grouped if grouped
.iter() .iter()
.flat_map(|merge| &merge.functions) .flat_map(|group| &group.functions)
.any(|f| f == info.name) .any(|f| f == info.name)
{ {
continue; continue;

View File

@ -36,7 +36,7 @@ math: |
{ x in RR | x "is natural" } $ { x in RR | x "is natural" } $
``` ```
Math mode makes a wide selection of [symbols]($category/math/symbols) like Math mode makes a wide selection of [symbols]($category/symbols/sym) like
`pi`, `dot.op`, or `RR` available. Many mathematical symbols are available in `pi`, `dot.op`, or `RR` available. Many mathematical symbols are available in
different variants. You can select between different variants by applying different variants. You can select between different variants by applying
[modifiers]($type/symbol) to the symbol. Typst further recognizes a number of [modifiers]($type/symbol) to the symbol. Typst further recognizes a number of

View File

@ -239,8 +239,8 @@ $ v := vec(x_1, x_2, x_3) $
``` ```
Some functions are only available within math mode. For example, the Some functions are only available within math mode. For example, the
[`cal`]($func/cal) function is used to typeset calligraphic letters commonly used for [`cal`]($func/cal) function is used to typeset calligraphic letters commonly
sets. The [math section of the reference]($category/math) provides a used for sets. The [math section of the reference]($category/math) provides a
complete list of all functions that math mode makes available. complete list of all functions that math mode makes available.
One more thing: Many symbols, such as the arrow, have a lot of variants. You can One more thing: Many symbols, such as the arrow, have a lot of variants. You can
@ -251,8 +251,9 @@ name:
$ a arrow.squiggly b $ $ a arrow.squiggly b $
``` ```
This notation is also available in markup mode, but the complete symbol name This notation is also available in markup mode, but the symbol name must be
with modifiers must then be enclosed in colons. See the documentation of the [text]($category/text) and [math sections]($category/math) for more details. preceded with `#sym.` there. See the [symbols section]($category/symbols/sym)
for a list of all available symbols.
## Review ## Review
You have now seen how to write a basic document in Typst. You learned how to You have now seen how to write a basic document in Typst. You learned how to