Skip to content

Conversation

@JL710
Copy link
Contributor

@JL710 JL710 commented Nov 11, 2025

This PR allows to pass a function that takes a line number and returns content to the line-numbers parameter. Thus allowing users to style the line numbers as they wish.

Example

#import "algorithmic.typ"

#import algorithmic: algorithm-figure, style-algorithm
#show: style-algorithm
#algorithm-figure(
  "Binary Search",
  vstroke: .5pt + luma(200),
  line-numbers: number => str(number),
  {
    import algorithmic: *
    Procedure(
      "Binary-Search",
      ("A", "n", "v"),
      {
        Comment[Initialize the search range]
        Assign[$l$][$1$]
        Assign[$r$][$n$]
        LineBreak
        While(
          $l <= r$,
          {
            Assign([mid], FnInline[floor][$(l + r) / 2$])
            IfElseChain(
              $A ["mid"] < v$,
              {
                Assign[$l$][$"mid" + 1$]
              },
              [$A ["mid"] > v$],
              {
                Assign[$r$][$"mid" - 1$]
              },
              Return[mid],
            )
          },
        )
        Return[*null*]
      },
    )
  },
)

@quachpas
Copy link
Collaborator

quachpas commented Nov 11, 2025

Hi @JL710, thanks for the patch. Can you add a test, corresponding documentation to the README please? The added info should be copied into the NEWS.md as well.

@JL710
Copy link
Contributor Author

JL710 commented Nov 12, 2025

@quachpas I added/updated a unittest and added documentation. Since I never worked with tytantic before I tried my best with the unittest. You might want to special check the unittest changes.

@quachpas
Copy link
Collaborator

Thanks, that's perfectly fine I'll check it on my side

Copy link
Collaborator

@quachpas quachpas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed the patch. Thank you, it looks nice and I'll be glad to merge this ! I've left comments in the PR for you to look at.

Copy link
Collaborator

@quachpas quachpas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I've reviewed the new changes, and that should be the final review. After this, I will merge this.

@quachpas quachpas merged commit 45f115d into typst-community:main Nov 23, 2025
4 checks passed
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.

2 participants