codelst is a Typst package for rendering sourcecode with line numbers and some other additions.
Usage
For Typst 0.6.0 or later, import the package from the typst preview repository:
#import "@preview/codelst:1.0.0": sourcecode
For Typst before 0.6.0 or to use codelst as a local module, download the package files into your project folder and import codelst.typ:
#import "codelst.typ": sourcecode
After importing the package, simply wrap any fenced code block in a call to #sourcecode():
#import "@preview/codelst:1.0.0": sourcecode
#sourcecode[```typ
#show "ArtosFlow": name => box[
#box(image(
"logo.svg",
height: 0.7em,
))
#name
]
This report is embedded in the
ArtosFlow project. ArtosFlow is a
project of the Artos Institute.
```]
Further documentation
See manual.pdf for a comprehensive manual of the package.
See example.typ for some quick usage examples.
Development
The documentation is created using Mantys, a Typst template for creating package documentation.
To compile the manual, Mantys needs to be available as a local package. Refer to Mantys’ manual for instructions on how to do so.
Changelog
v1.0.0
- Complete rewrite of code rendering.
- New options for
#sourcecode():lang: Overwrite code language setting.numbers-first: First line number to show.numbers-step: Only show every n-th number.frame: Set a frame (replaces<codelst>label.)- Merged
line-numbersandnumberingoptions.
- Removed
#numbers-style()function.numbers-styleoption now gets passedcounter.display().
- Removed
<codelst>label. codelst-styleonly setsbreakablefor figures.- New
codelstfunction to setup a catchall show rules forrawtext. label-regex: nonedisables labels parsing.- Code improvements and refactorings.
v0.0.5
- Fixed insets for line highlights.
- Added
numbers-widthoption to manually set width of line numbers column.- This allows line numbers on margins by setting
numbers-widthto0ptor a negative number like-1em.
- This allows line numbers on margins by setting
v0.0.4
- Fixed issue with context unaware syntax highlighting.
v0.0.3
- Removed call to
#read()from#sourcefile(). - Added
continue-numberingargument to#sourcecode(). - Fixed problem with
showrangehaving out of range line numbers.
v0.0.2
- Added a comprehensive manual.
- Fixed crash for missing
langattribute inrawelement.
v0.0.1
- Initial version submitted to typst/packages.