Skip to content

Releases: platformer/typst-algorithms

algo v0.3.4

09 Nov 18:31
Compare
Choose a tag to compare

Bug Fixes

  • resolve deprecation warnings by migrating to context syntax

Notes

  • I'm still deciding whether or not I'll wait for Typst to add custom types before making a major update to the package. Regardless, the next major version will probably see significant changes to the package's API. Most significantly, I will likely remove code from the package in the interest of making the package more focused and because I think there are other packages that just do it better. So only continue to use this package for writing pseudocode.

algo v0.3.3

21 Sep 00:02
Compare
Choose a tag to compare

Bug Fixes

  • Fixed issue where raw text in code may have gotten their ascenders cut off
  • Fixed strange behavior when text line-wrapped in code

algo v0.3.2

27 Aug 23:23
Compare
Choose a tag to compare

Bug Fixes

  • Previously, code would ignore raw input if it wasn't part of a sequence (i.e. if there was no whitespace around your raw text, nothing would be outputted). This is no longer the case.

algo v0.3.1

18 Aug 00:23
Compare
Choose a tag to compare

New Features

  • Added inline parameter to comment — By passing true to inline, the comment will be displayed in place rather than on the right side.

  • Added no-emph function — Passing content to no-emph will prevent that content from being automatically emphasized in an algo element via strong-keywords.

algo v0.3.0

08 Aug 00:00
Compare
Choose a tag to compare

Breaking Changes

  • Removed comment-color parameter from algo — Comments in an algo element are now styled via comment-styles (see New Features).

  • Made algo and code elements unbreakable by default — It is difficult to make indent guides look good under all circumstances when figures are allowed to break across pages. Since users will almost never want their algorithms to be broken anyway, this behavior was changed. If you wish to typeset very long code blocks that contain entire programs, then you should probably use a different library. You may also override the new behavior with the breakable parameter at the risk of indent guides looking incorrect.

  • Removed ability to pass multiple raw blocks to code — It used to be possible to pass multiple raw blocks with differing languages to a single code element, and they would be displayed contiguously as one might expect. This needlessly complicated the logic, as there's little reason for a user to do this anyway. code now expects only a single raw block to be passed to itself.

  • Enabled strong-keywords parameter in algo by default — Bold keywords look aesthetically better most of the time, so they are now the default.

  • Added "repeat" and "until" to algo's default keyword list — Occurrences of "repeat" and "until" in an algo will now be strongly emphasized by default.

  • Added uppercase variations to algo's default keyword list — For any word in the default list of keywords, the uppercase form will now be strongly emphasized as well (e.g. "for" and "For"). This rule does not apply if the user explicitly passes their own list via the keywords parameter.

  • Aligned text in algo and code to the bottom of each row — Previously, main body text in algo elements and raw text in code elements were aligned to the top of each row. They are now instead aligned to the bottom, sharing a baseline with line numbers. This change only affects uses of algo and code where line numbers were bigger than other text.

New Features

  • Added breakable parameter to algo and code — Setting breakable to true will allow algo and code elements to break across pages.

  • Added main-text-styles, comment-styles, and line-number-styles parameters — algo now supports these three parameters, and code supports just main-text-styles and line-number-styles. Each of these parameters takes a dictionary of styling options for the corresponding text in the element. Possible options include anything that is supported by Typst's native text function.

  • tab-size parameter for code elements is now determined automatically — If tab-size is unspecified, it will be determined automatically based on the first line that starts with whitespace.

  • Added indent-guides-offset parameter to algo and code — Passing a length to indent-guides-offset will horizontally shift the position of indent guides by that amount.

  • Added block-align parameter to algo and code — Setting block-align determines the alignment of the element on the page. Passing none will cause the block to be returned as-is.

  • Added radius parameter to algo and code — Passing a length to radius will round the corners of the element.

  • Added header parameter to algo — Passing content to header will add a custom header to an algo element. This overrides title and parameters.

Bug Fixes

  • Made indent guides in algo elements account for the size of comments — Previously, if the content of a comment was vertically taller than the corresponding text in the algorithm, the indent guides on that line would be too short. Indent guides should now be the correct length regardless of the size of the algorithm text or comment text.

  • Made internal alignments insensitive to align calls — Previously, using align on an algo or code element may have affected the internal alignments of indent guides and text. This is no longer the case.

  • Passing raw text with an unspecified language to code no longer produces a compiler error.

  • Calling algo with an empty body no longer produces a compiler error.

  • Calling code with an empty body no longer produces a compiler error.

  • code now maintains correct syntax highlighting for languages with context-sensitive keywords (such as Typst itself).

  • Fixed issue where an excess dedent in an algo element would cause an unrelated assertion to fail.

Miscellaneous

  • Changed assert messages to be more clear that they originate from algo.typ

typst-algorithms v0.2.0

04 Jul 23:49
Compare
Choose a tag to compare

Breaking Changes

  • Removed implicit-linebreaks parameter from algo — it was mostly experimental in the first place, and it was very easily broken. Explicit linebreaks just work better.

  • Started treating trailing indentation commands as belonging to the next line — it used to be that occurrences of #i and #d after a linebreak but before text would successfully apply the new indentation level to the following line. The logic for this was complicated and fragile due to relying on parsing the result of a repr call, so it was removed. Now, the result of any indentation commands will only be reflected after the next linebreak.

New Features

  • Added #comment function — use the #comment function in an algo element to add a comment to a line. algo also has the accompanying parameters comment-prefix and comment-color to style comments that appear in the algorithm.

  • Added strong-keywords parameter to algo — setting strong-keywords to true in an algo call will automatically emphasize common keywords that appear in your algorithm. Pass a list of strings to the accompanying keywords parameter if you want to have different keywords than the default.

  • Added indent-guides parameter to algo and code — both algo and code now have an indent-guides parameter that takes a stroke value. code has an accompanying tab-size parameter that allows you to specify how big your tabs are in your raw text.

typst-algorithms v0.1.1

12 Apr 00:29
a9f9bba
Compare
Choose a tag to compare
  • updated to new enumerate syntax according to Typst's latest release

typst-algorithms v0.1.0

11 Apr 20:50
07f77dd
Compare
Choose a tag to compare
  • algo.typ module
    • algo function: interprets and renders passed content as a pseudocode algorithm
    • code function: renders passed raw text as a line-numbered code block
  • algo-example.typ: example code file using algo.typ