Enumerating links

I’m trying to make the following transformation with a function:

#show link: underline

#enum("https://mathworld.wolfram.com/Factorization.html", "https://mathworld.wolfram.com/Decomposition.html")

#enum([https://mathworld.wolfram.com/Factorization.html], [https://mathworld.wolfram.com/Decomposition.html])

but I’m unable to satisfy enum()'s requirements, anyone think they would know how?

If you are writing by hand:

+ https://mathworld.wolfram.com/Factorization.html
+ https://mathworld.wolfram.com/Decomposition.html

If you are developing a script, there are many methods:

#show link: underline

// Prepare links:
// 1. Create a https://typst.app/docs/reference/text/raw/
// 2. Get its text
// 3. Split into lines
#let links = ```
https://mathworld.wolfram.com/Factorization.html
https://mathworld.wolfram.com/Decomposition.html
```.text.split(regex("\r?\n"))
// You may also find `read` helpful.
// https://typst.app/docs/reference/data-loading/read/

= Method 1
#enum(..links.map(link).map(enum.item))

= Method 2
// Typst has code {…} and markup […] modes.
// https://typst.app/docs/reference/syntax/#modes
#for l in links [
  // Here is in the markup mode.
  + #link(l)
]

= Method 3
#for l in links {
 // Here is in the code mode.
  enum.item(link(l))
}
// `enum.item` will be collected into `enum` automatically.

You can choose the one that you understand. (If you need further explanation, please reply. I or other people on the forum will help.)

1 Like