v0.3.0
版本发布时间: 2023-08-08 08:00:47
platformer/typst-algorithms最新发布版本:v0.3.3(2023-09-21 08:02:19)
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
1、 algo.typ 24.66KB