Skip to content

Added front-matter parameter to #algo(). #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nervecenter
Copy link

Added front-matter parameter to #algo() which places given content below the header, but above the algorithm table and line numbers.

Example:

#algo(
  title: "Fib",
  parameters: ("n",),
  front-matter: [
    *Input*: The number in the Fibonacci sequence $n$ to generate.\
    *Output*: The $n$th number in the Fibonacci sequence.
  ]
)[
  if $n < 0$:#i\
    return null#d\
  if $n = 0$ or $n = 1$:#i\
    return $n$#d\
  \
  let $x <- 0$\
  let $y <- 1$\
  for $i <- 2$ to $n-1$:#i\
    let $z <- x+y$\
    $x <- y$\
    $y <- z$#d\
    \
  return $x+y$
]

Outputs the following:
typst_alg_fib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant