Releases: platformer/typst-algorithms
algo v0.3.4
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
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
Bug Fixes
- Previously,
code
would ignoreraw
input if it wasn't part of asequence
(i.e. if there was no whitespace around yourraw
text, nothing would be outputted). This is no longer the case.
algo v0.3.1
New Features
-
Added
inline
parameter tocomment
— By passingtrue
toinline
, the comment will be displayed in place rather than on the right side. -
Added
no-emph
function — Passing content tono-emph
will prevent that content from being automatically emphasized in analgo
element viastrong-keywords
.
algo v0.3.0
Breaking Changes
-
Removed
comment-color
parameter fromalgo
— Comments in analgo
element are now styled viacomment-styles
(see New Features). -
Made
algo
andcode
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 thebreakable
parameter at the risk of indent guides looking incorrect. -
Removed ability to pass multiple
raw
blocks tocode
— It used to be possible to pass multipleraw
blocks with differing languages to a singlecode
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 singleraw
block to be passed to itself. -
Enabled
strong-keywords
parameter inalgo
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 analgo
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 thekeywords
parameter. -
Aligned text in
algo
andcode
to the bottom of each row — Previously, main body text inalgo
elements and raw text incode
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 ofalgo
andcode
where line numbers were bigger than other text.
New Features
-
Added
breakable
parameter toalgo
andcode
— Settingbreakable
totrue
will allowalgo
andcode
elements to break across pages. -
Added
main-text-styles
,comment-styles
, andline-number-styles
parameters —algo
now supports these three parameters, andcode
supports justmain-text-styles
andline-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 nativetext
function. -
tab-size
parameter forcode
elements is now determined automatically — Iftab-size
is unspecified, it will be determined automatically based on the first line that starts with whitespace. -
Added
indent-guides-offset
parameter toalgo
andcode
— Passing a length toindent-guides-offset
will horizontally shift the position of indent guides by that amount. -
Added
block-align
parameter toalgo
andcode
— Settingblock-align
determines the alignment of the element on the page. Passingnone
will cause the block to be returned as-is. -
Added
radius
parameter toalgo
andcode
— Passing a length toradius
will round the corners of the element. -
Added
header
parameter toalgo
— Passing content toheader
will add a custom header to analgo
element. This overridestitle
andparameters
.
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, usingalign
on analgo
orcode
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 fromalgo.typ
typst-algorithms v0.2.0
Breaking Changes
-
Removed
implicit-linebreaks
parameter fromalgo
— 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 arepr
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 analgo
element to add a comment to a line.algo
also has the accompanying parameterscomment-prefix
andcomment-color
to style comments that appear in the algorithm. -
Added
strong-keywords
parameter toalgo
— settingstrong-keywords
totrue
in analgo
call will automatically emphasize common keywords that appear in your algorithm. Pass a list of strings to the accompanyingkeywords
parameter if you want to have different keywords than the default. -
Added
indent-guides
parameter toalgo
andcode
— bothalgo
andcode
now have anindent-guides
parameter that takes a stroke value.code
has an accompanyingtab-size
parameter that allows you to specify how big your tabs are in your raw text.
typst-algorithms v0.1.1
- updated to new
enumerate
syntax according to Typst's latest release
typst-algorithms v0.1.0
algo.typ
modulealgo
function: interprets and renders passed content as a pseudocode algorithmcode
function: renders passed raw text as a line-numbered code block
algo-example.typ
: example code file usingalgo.typ