Open TimotheAlbouy opened 6 months ago
I experimented with this when initially writing the package, but I found it to be more cumbersome to write and edit due to all the brackets. That's why I wanted to make algo's syntax as 1-to-1 as possible. However, I recognize that constantly typing newlines and indents can be annoying. For the next major version, I'm planning on leveraging Typst's list syntax for writing the algorithms, similar to one of the options lovelace provides. This moves the indentation information to Typst's built in lists rather than being a command typed by the user.
I think you are right, typst allows for much lighter syntax, we shouldn't limit ourselves to how a 20+-year-old Latex package did it.
Following your idea, I have created a small pseudocode package that leverages typst's list syntax and mimics algorithm2e's styling nearly perfectly. I've also added the capability to reference lines. I will use it for my personal use, but if you are interested I can send you my code.
If you feel comfortable sharing, sure! Would be very helpful
I have sent you an email to your gmail address ;)
Thank you for this package. It surely is the most mature package for writing pseudocode in typst yet.
However, I find the syntax with indents/dedents not very ergonomic. I am used to LaTeX's algorithm2e syntax for writing pseudocode, where you define loops/if clauses/functions... using macros. I think that in typst, this would translate very naturally to function calls.
For example, the following LaTeX/algorithm2e code:
would translate to the following typst/algo code:
Here, the user would define their own function/if/else-if/else/while keywords, making the framework less opinionated. The
algo-block()
function would be used to define a new keyword for a block of code, whereas thealgo-inline()
function would be used to define an inline statement (e.g., a "if-then" statement on one line). Thepreamble-end
option would specify the keyword at the end of the first part of the statement (e.g., the "then" part of a "if-then" statement).The
algorithmic
typst package already uses this syntax, which is more elegant as the one currently used in thealgo
package IMHO, as it relieves the end-user of doing all the tedious (in/de)denting. However,algorithmic
lacks all the nice features of thealgo
package.What do you think? Would this syntax be feasible for the
algo
package? If so, would it be desirable?