Introducing new contributor: @QuadnucYard. Welcome! 🎉
For single item code block, typstyle will try to keep it inline if it fits in a single line and it's inline in original code.
For example, you will get following code:
123
#{
let x = if true { 1 } else { 2 }
}
Instead of:
1234567
#{
let x = if true {
1} else {
2}
}
Typstyle now strip excessive newlines in code blocks. Previously, typstyle will keep all newlines in code blocks. Now it will strip newlines at beginning and end of code blocks. It will also strip newlines in the middle of code blocks if there are more than 2 consecutive newlines.
For example, the following code:
12345678
#{
let x = 1
let y = 2
}
After formatting, it will become:
12345
#{
let x = 1
let y = 2
}
Formatting block comments are now improved. Previously, leading spaces in block comments are blindly removed. Now typstyle will keep leading spaces in block comments if they are consistent. Typstyle will also try to align * in block comments.
For example, the following code:
1 2 3 4 5 6 7 8 9101112131415161718
#{
let x = 1 /* Attached block comment
that spans
multiple lines
*/ /*Block comment
that spans
multiple lines
*/ /*Block comment with leading stars
* that *spans
* multiple *lines
*/
}
Will be formatted as:
1 2 3 4 5 6 7 8 9101112131415161718
#{
let x = 1 /* Attached block comment
that spans
multiple lines
*/ /*Block comment
that spans
multiple lines
*/ /*Block comment with leading stars
* that *spans
* multiple *lines
*/
}
Fix: context expressions are now longer surrounded by unneeded parentheses. Previously, if a context expression spans multiple lines, typstyle will wrap it in parentheses. Now it doesn't.
Typstyle now keeps spaces around math-delimited when there is already space around it. This prevents a bug when removing the space can cause wrong format result.
Generate shell completions for the given shell to stdout
Usage: typstyle completions <SHELL>
Arguments:
<SHELL> The shell to generate completions for [possible values: bash, elvish, fish, powershell, zsh]
Bug fix: Typstyle previously fails to correctly format inline triple backtick code block without a lang tag or an empty inline triple backtick code block with only a lang tag. Now it is fixed.
Bug fix: previously when a destructing pattern has extra parentheses, typstyle will completely remove everything inside the parentheses. Now it is fixed.
Typstyle now collapses extra parentheses in expression.
Fix #97. Typstyle previously add an extra newline for table and grid when there is no positional argument and there are extra arguments. Now it doesn't add an extra newline.
Typstyle cli now returns non-zero exit code when there are formatting errors.
Typstyle now keeps newlines in function call args. Multiple newlines in function call args are common in fletcher diagrams. Before this release, typstyle removes all extra newlines in function call args. Now it keeps them as they are.
For tables, if typstyle is unable to format it in a column-aware way, it will now format each arg, but do not reflow them. That is, the relative position of each arg is kept. If you put something in a single line, it will stay in a single line. Newlines are also kept.
Example
12345678
#table(columns: 4 * (1fr,),
[a], [b], [c], [d],
fill: (_, y) => if y == 0 { black },
table.cell(rowspan: 2)[aa], table.cell(colspan: 2)[bc], [d],
[b], table.cell(colspan: 2)[cd],
)
After formatting, it will become this. Notice the relative position of each arg is kept.
1 2 3 4 5 6 7 8 910
#table(columns: 4 * (1fr,),
[a], [b], [c], [d],
fill: (_, y) => if y == 0 {
black
},
table.cell(rowspan: 2)[aa], table.cell(colspan: 2)[bc], [d],
[b], table.cell(colspan: 2)[cd],
)
Typstyle now keeps extra newlines in markup mode. Multiple newlines are sometimes used to separate different sections in a document or act as a paragraph placeholder. Typstyle now keeps them as they are.
Typstyle now can format table and grid in a "column-aware" way. It now recognizes basic patterns and column numbers, and put a single row in a single line if possible.
(#49) typstyle cli now support multiple input files. If multiple files are provided, they will be processed in order.
This is especially useful when you want to format multiple files inplace with a single command.
Spread args/array/dict into multiple lines if the first space in it contains a newline. This enables flexible control over the formatting of spread args.
This is called flavor detection.