diff --git a/docs/src/html.rs b/docs/src/html.rs index 9fbb4fd8d..ac48952d8 100644 --- a/docs/src/html.rs +++ b/docs/src/html.rs @@ -125,15 +125,10 @@ impl<'a> Handler<'a> { "unsupported link type: {ty:?}", ); - let mut link = self + *dest = self .handle_link(dest) - .unwrap_or_else(|| panic!("invalid link: {dest}")); - - if !link.contains('#') && !link.ends_with('/') { - link.push('/'); - } - - *dest = link.into(); + .unwrap_or_else(|| panic!("invalid link: {dest}")) + .into(); } // Inline raw. @@ -226,16 +221,36 @@ impl<'a> Handler<'a> { let info = func.info()?; route.push_str(info.category); route.push('/'); - route.push_str(name); - route.push('/'); - if let Some(param) = param { - route.push_str("#parameters--"); - route.push_str(param); + + if let Some(group) = GROUPS + .iter() + .find(|group| group.functions.iter().any(|func| func == info.name)) + { + 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 { route.push_str(rest); } + if !route.contains('#') && !route.ends_with('/') { + route.push('/'); + } + Some(route) } } diff --git a/docs/src/lib.rs b/docs/src/lib.rs index c9e7af25a..57f8657ef 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -209,7 +209,7 @@ fn category_page(resolver: &dyn Resolver, category: &str) -> PageModel { // Skip grouped functions. if grouped .iter() - .flat_map(|merge| &merge.functions) + .flat_map(|group| &group.functions) .any(|f| f == info.name) { continue; diff --git a/docs/src/reference/details.yml b/docs/src/reference/details.yml index 5d7ddfd17..fff1b7479 100644 --- a/docs/src/reference/details.yml +++ b/docs/src/reference/details.yml @@ -36,7 +36,7 @@ math: | { 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 different variants. You can select between different variants by applying [modifiers]($type/symbol) to the symbol. Typst further recognizes a number of diff --git a/docs/src/tutorial/1-writing.md b/docs/src/tutorial/1-writing.md index 037801b5c..50ae699c4 100644 --- a/docs/src/tutorial/1-writing.md +++ b/docs/src/tutorial/1-writing.md @@ -239,8 +239,8 @@ $ v := vec(x_1, x_2, x_3) $ ``` Some functions are only available within math mode. For example, the -[`cal`]($func/cal) function is used to typeset calligraphic letters commonly used for -sets. The [math section of the reference]($category/math) provides a +[`cal`]($func/cal) function is used to typeset calligraphic letters commonly +used for sets. The [math section of the reference]($category/math) provides a 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 @@ -251,8 +251,9 @@ name: $ a arrow.squiggly b $ ``` -This notation is also available in markup mode, but the complete symbol name -with modifiers must then be enclosed in colons. See the documentation of the [text]($category/text) and [math sections]($category/math) for more details. +This notation is also available in markup mode, but the symbol name must be +preceded with `#sym.` there. See the [symbols section]($category/symbols/sym) +for a list of all available symbols. ## Review You have now seen how to write a basic document in Typst. You learned how to