Skip to content

Releases: Enter-tainer/typstyle

v0.13.8

21 May 14:29
v0.13.8
Compare
Choose a tag to compare
  • Bug fix: typstyle previously will break inline equations if they has alignments. Now it is fixed. It will never add paddings to align inline equations now.
  • Feature: typstyle doesn't enforce trailing backslash in math equations with alignments now.
  • Feature: Previously, typstyle will try to put the last argument of a function call in the same line as the function call when certain conditions are met. Now it is enhanced. In this version, if the last argument is an array or a dict, typstyle will only do this if it is the only array/dict argument.

v0.13.7

15 May 14:57
v0.13.7
Compare
Choose a tag to compare
  • Cli: typstyle now supports formatting dirs natively. You can use typstyle -i <dir> to format all files in the directory. Given that, typstyle format-all is deprecated and will be removed in the future.
  • Cli: typstyle now uses -l or --line-width instead of -c/--column to specify the line width. The -c/--column option is deprecated and will be removed in the future.
  • Cli: typstyle now uses --indent-width instead of --tab-width to specify the indent width. The --tab-width option is deprecated and will be removed in the future. However, -t is still available.
  • Feature: when --wrap-text is enabled, typstyle will now keep the line breaks after backslashes in markup. Previously, it is not treated specially.
  • Feature: typstyle now keep spaces around fractions in math equations. Previously, it always added a space before and after the fraction.

v0.13.6

11 May 15:22
v0.13.6
Compare
Choose a tag to compare

Changelog

v0.13.6 - [2025-05-11]

  • Bug fix: #272. Previously, typstyle will remove the space between variable and underscore in math equations. $ #mysum _(i=0) $ for example, will be formatted as $ #mysum_(i=0) $. Now it is fixed.
  • Enhancement: #273. When formatting math equations with alignments and multiline cells, previous typstyle versions will introduce excessive spaces. Now it is fixed.
  • Enhancement: #280. When wrap text is enabled, previous typstyle will mess up the formatting of labels. Now it is fixed.

v0.13.5 - [2025-05-07]

  • Bug fix: Typstyle previously will panic if there is only a space in math function call. Now it is fixed.
  • Bug fix: Typstyle previously will not converge if there are multiple newlines in a function call. Now it is fixed.

v0.13.4 - [2025-04-30]

  • Feature: typstyle cli now enables import sorting by default. You can disable it with --no-reorder-import-items flag.

  • Feature: typstyle now supports --wrap-text flag to wrap texts in the markup. It is considered as experimental and may not work in all cases. Please report any issues you encounter.

    For example, this code:

    Let's say you have a long text that needs to be wrapped in the markup. This is a very long sentence that needs to be wrapped in the markup. It should be wrapped in the markup.

    Will be formatted as following when column width is 80 and --wrap-text is enabled:

    Let's say you have a long text that needs to be wrapped in the markup. This is a
    very long sentence that needs to be wrapped in the markup. It should be wrapped
    in the markup.
  • Feature: typstyle now tries to align &s in math equations, even if the cells are multiline. Currently it it works in most cases, except the following:

    • Has multiline Str or Raw descendants.
    • Not following a linebreak when in MathDelimited or Args.
    • Across args of functions such as cases.

    For example, this code:

    $
    F_n &= sum_(i=1)^n i^2 & n > 0 \
    a &< b+1 & forall b < 1
    $

    Will be formatted as:

    $
      F_n & = sum_(i=1)^n i^2 &        n > 0 \
        a & < b+1             & forall b < 1 \
    $
  • Feature: typstyle now generate more compact result when formatting complex function calls. Similar to what rustfmt does, when the only argument is combinable, it will be put in the same line as the function call. When the last argument is blocky, it will also be put in the same line if possible.

    For example, this code:

    #figure(
      fletcher.diagram(
        node-outset: .5em,
        node-stroke: .075em,
    
        node(
          (+1,0,),
          [variable],
          radius: 3em,
        ), // test
      ))

    Will be formatted as:

    #figure(fletcher.diagram(
      node-outset: .5em,
      node-stroke: .075em,
    
      node((+1, 0), [variable], radius: 3em), // test
    ))

    For another example, this code:

    #set page(
      margin: 0.5in,
      footer: context {
        if counter(page).display() == "2" {
          [test]
        } else {
          []
        }
      }
    )

    Will be formatted as:

    #set page(margin: 0.5in, footer: context {
      if counter(page).display() == "2" {
        [test]
      } else {
        []
      }
    })

    Due to the limitations of the currently used pretty engine, there is still room for improvement in some cases.

v0.13.3 - [2025-04-10]

  • Feature: Unified equation layout and removed indent for non-block equations
    • Non-block equations are no longer indented, which works well in most reasonable cases
    • Nodes with multiline comments are now treated as multiline
    • Improved comment attachment mechanism
  • Fix: Improved handling of comments directly in equations and spaces in math
    • Correctly handles in-equation comments before and after Math
    • Fixed infinite spaces added before // in math
    • Fixed extra indent of array args in math
    • Optimized spaces handling in MathAttach and MathRoot
  • Fix: Addressed list layout issues
    • Fixed indent and grouping issues in list layouts
    • Fixed missing separators in list layouts mixed with comments

v0.13.2 - [2025-03-28]

  • Feature: Typstyle can format code in markup lines now. Linebreaks are suppressed inside to ensure compact layout.
  • Feature: Typstyle can format math equations with comments and hashes now. Previously they are skipped.
  • Feature: Improved formatting of math delimited. Linebreaks are kept as is.
  • Experimental feature: Typstyle CLI will sort import items in a single import statement if --reorder-import-items is passed. It would be enabled by default in the future.
  • Added a 3rd-party typstyle-action maintained by @grayespinoza.

v0.13.1 - [2025-03-20]

  • Bump to typst v0.13.1
  • Typstyle now uses braces ({}) instead of parens (()) when the closure body is not a chainable binary expression
#fun(() => {
  aaa
})
instead of
#fun(() => (
  aaa
))
  • Fix mis-format when linebreak \ appears at the end of a inline math equation.
  • Fix mis-format when line comment appears in a multiline import statement.

v0.13.0 - [2025-02-22]

  • Bump to typst v0.13.0
  • Regression: In typst v0.13.0, PR #5310 changes the parsing behavior of comments when it presenting in list, enum and term list. In this verison, the indent level of the comment in list, enum and term list determined by the next item, not the previous item. For example,
- Fruit
  - Apple
  - Banana
  // - Orange
- Vegetable
  - Carrot
  - Tomato

will be formatted as this in this version. Note that the // - Orange is misindented. It is indented to the same level as - Vegetable. It works perfectly in previous versions. So if you want to keep the old behavior, please keep using typstyle v0.12.x at this moment.

- Fruit
  - Apple
  - Banana
// - Orange
- Vegetable
  - Carrot
  - Tomato

v0.12.15 - [2025-02-16]

  • Feat: add --tab-width cli option to set the number of spaces for indentation. The default value is 2.
  • Fix: typstyle-cli now outputs the original source when the input syntax is erroneous.
  • Fix: issues with list/enum/term item indent and linebreak with comments are fixed. Now linebreaks in items are preserved. Items in content blocks will be surrounded with linebreaks when necessary (also to avoid ambiguity).

For example, the code

+
  + xyz

-
  xyz

- //foo
  - xyz
  //bar

/ 4:
  // 4
  / 44: // 44
    444

was incorrectly formatted to

+ + xyz

- xyz

- //foo
- xyz
  //bar

/ 4: // 4
  / 44: // 44
  444

Now it is correctly unchanged.

And

#{
  [- single]
  [- indented
  - less
  ]
  [- indented
   - same
  - then less
   - then same
  ]
  [- indented
    - more
   - then same
  - then less
  ]
}

will be correctly formatted to

#{
  [- single]
  [
    - indented
    - less
  ]
  [
    - indented
    - same
    - then less
      - then same
  ]
  [
    - indented
      - more
    - then same
    - then less
  ]
}

v0.12.14 - [2024-12-27]

  • Fix: typstyle-cli previously add an extra newline at the end of the file. Now it is fixed.
  • Fix: typstyle now correctly strip leading spaces in markup
  • Feat: typstyle-core now has very basic support for range formatting.

v0.12.13 - [2024-12-21]

  • Fix: typstyle previously incorrectly remove comments in math equations. Now it is fixed.
  • Cli:
    • typstyle now reports error when the input file is invalid.
    • typstyle --check no longer changes the file content.
    • Other minor improvements.

v0.12.12 - [2024-12-16]

No changes. We failed to publish the previous release because of the ci issue.

v0.12.11 - [2024-12-16]

Packaging: We've split typstyle crate into two independent crates: typstyle and typstyle-core. typstyle is the CLI tool, and typstyle-core is the core library. The npm package is now typstyle-core, typstyle on npm will be deprecated in the future.

  • Fix: // @typstyle off not working in certain cases. See #182
  • Feature: dot chain formatting is more smart now. We will only break dot chain into multiple lines if it is long enough or complex enough. For example, the following result is generated by typstyle previously:
#{
  cetz
    .draw
    .group({
      cetz.draw.translate(node.pos.xyz)
      for (i, extrude) in node.extrude.enumerate() {
        cetz
          .draw
          .set-style(
            fill: if i == 0 { node.fill },
            stroke: node.stroke,
          )
        (node.shape)(node, extrude)
      }
    })
}

Now it will be formatted as following. This is more readable and compact:

#{
  cetz.draw.group({
    cetz.draw.translate(node.pos.xyz)
    for (i, extrude) in node.extrude.enumerate() {
      cetz.draw.set-style(
        fill: if i == 0 { node.fill },
        stroke: node.stroke,
      )
      (node.shape)(node, extrude)
    }
  })
}

v0.12.10 - [2024-12-12]

  • Fix: musl build is now statically linked. This fixes the issue that the musl build doesn't work on systems other than alpine.
  • Typstyle now break content blocks into multiple lines if they have leading spaces and trailing spaces.

For example, the following code is not formattable by typstyle previously:

#{
  let res = if true [ The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines. ] else [ The Result is definitely false. And it is a very long sentence that need...
Read more

v0.13.5

07 May 15:05
v0.13.5
Compare
Choose a tag to compare

Changelog

v0.13.5 - [2025-05-07]

  • Bug fix: Typstyle previously will panic if there is only a space in math function call. Now it is fixed.
  • Bug fix: Typstyle previously will not converge if there are multiple newlines in a function call. Now it is fixed.

v0.13.4 - [2025-04-30]

  • Feature: typstyle cli now enables import sorting by default. You can disable it with --no-reorder-import-items flag.

  • Feature: typstyle now supports --wrap-text flag to wrap texts in the markup. It is considered as experimental and may not work in all cases. Please report any issues you encounter.

    For example, this code:

    Let's say you have a long text that needs to be wrapped in the markup. This is a very long sentence that needs to be wrapped in the markup. It should be wrapped in the markup.

    Will be formatted as following when column width is 80 and --wrap-text is enabled:

    Let's say you have a long text that needs to be wrapped in the markup. This is a
    very long sentence that needs to be wrapped in the markup. It should be wrapped
    in the markup.
  • Feature: typstyle now tries to align &s in math equations, even if the cells are multiline. Currently it it works in most cases, except the following:

    • Has multiline Str or Raw descendants.
    • Not following a linebreak when in MathDelimited or Args.
    • Across args of functions such as cases.

    For example, this code:

    $
    F_n &= sum_(i=1)^n i^2 & n > 0 \
    a &< b+1 & forall b < 1
    $

    Will be formatted as:

    $
      F_n & = sum_(i=1)^n i^2 &        n > 0 \
        a & < b+1             & forall b < 1 \
    $
  • Feature: typstyle now generate more compact result when formatting complex function calls. Similar to what rustfmt does, when the only argument is combinable, it will be put in the same line as the function call. When the last argument is blocky, it will also be put in the same line if possible.

    For example, this code:

    #figure(
      fletcher.diagram(
        node-outset: .5em,
        node-stroke: .075em,
    
        node(
          (+1,0,),
          [variable],
          radius: 3em,
        ), // test
      ))

    Will be formatted as:

    #figure(fletcher.diagram(
      node-outset: .5em,
      node-stroke: .075em,
    
      node((+1, 0), [variable], radius: 3em), // test
    ))

    For another example, this code:

    #set page(
      margin: 0.5in,
      footer: context {
        if counter(page).display() == "2" {
          [test]
        } else {
          []
        }
      }
    )

    Will be formatted as:

    #set page(margin: 0.5in, footer: context {
      if counter(page).display() == "2" {
        [test]
      } else {
        []
      }
    })

    Due to the limitations of the currently used pretty engine, there is still room for improvement in some cases.

v0.13.3 - [2025-04-10]

  • Feature: Unified equation layout and removed indent for non-block equations
    • Non-block equations are no longer indented, which works well in most reasonable cases
    • Nodes with multiline comments are now treated as multiline
    • Improved comment attachment mechanism
  • Fix: Improved handling of comments directly in equations and spaces in math
    • Correctly handles in-equation comments before and after Math
    • Fixed infinite spaces added before // in math
    • Fixed extra indent of array args in math
    • Optimized spaces handling in MathAttach and MathRoot
  • Fix: Addressed list layout issues
    • Fixed indent and grouping issues in list layouts
    • Fixed missing separators in list layouts mixed with comments

v0.13.2 - [2025-03-28]

  • Feature: Typstyle can format code in markup lines now. Linebreaks are suppressed inside to ensure compact layout.
  • Feature: Typstyle can format math equations with comments and hashes now. Previously they are skipped.
  • Feature: Improved formatting of math delimited. Linebreaks are kept as is.
  • Experimental feature: Typstyle CLI will sort import items in a single import statement if --reorder-import-items is passed. It would be enabled by default in the future.
  • Added a 3rd-party typstyle-action maintained by @grayespinoza.

v0.13.1 - [2025-03-20]

  • Bump to typst v0.13.1
  • Typstyle now uses braces ({}) instead of parens (()) when the closure body is not a chainable binary expression
#fun(() => {
  aaa
})
instead of
#fun(() => (
  aaa
))
  • Fix mis-format when linebreak \ appears at the end of a inline math equation.
  • Fix mis-format when line comment appears in a multiline import statement.

v0.13.0 - [2025-02-22]

  • Bump to typst v0.13.0
  • Regression: In typst v0.13.0, PR #5310 changes the parsing behavior of comments when it presenting in list, enum and term list. In this verison, the indent level of the comment in list, enum and term list determined by the next item, not the previous item. For example,
- Fruit
  - Apple
  - Banana
  // - Orange
- Vegetable
  - Carrot
  - Tomato

will be formatted as this in this version. Note that the // - Orange is misindented. It is indented to the same level as - Vegetable. It works perfectly in previous versions. So if you want to keep the old behavior, please keep using typstyle v0.12.x at this moment.

- Fruit
  - Apple
  - Banana
// - Orange
- Vegetable
  - Carrot
  - Tomato

v0.12.15 - [2025-02-16]

  • Feat: add --tab-width cli option to set the number of spaces for indentation. The default value is 2.
  • Fix: typstyle-cli now outputs the original source when the input syntax is erroneous.
  • Fix: issues with list/enum/term item indent and linebreak with comments are fixed. Now linebreaks in items are preserved. Items in content blocks will be surrounded with linebreaks when necessary (also to avoid ambiguity).

For example, the code

+
  + xyz

-
  xyz

- //foo
  - xyz
  //bar

/ 4:
  // 4
  / 44: // 44
    444

was incorrectly formatted to

+ + xyz

- xyz

- //foo
- xyz
  //bar

/ 4: // 4
  / 44: // 44
  444

Now it is correctly unchanged.

And

#{
  [- single]
  [- indented
  - less
  ]
  [- indented
   - same
  - then less
   - then same
  ]
  [- indented
    - more
   - then same
  - then less
  ]
}

will be correctly formatted to

#{
  [- single]
  [
    - indented
    - less
  ]
  [
    - indented
    - same
    - then less
      - then same
  ]
  [
    - indented
      - more
    - then same
    - then less
  ]
}

v0.12.14 - [2024-12-27]

  • Fix: typstyle-cli previously add an extra newline at the end of the file. Now it is fixed.
  • Fix: typstyle now correctly strip leading spaces in markup
  • Feat: typstyle-core now has very basic support for range formatting.

v0.12.13 - [2024-12-21]

  • Fix: typstyle previously incorrectly remove comments in math equations. Now it is fixed.
  • Cli:
    • typstyle now reports error when the input file is invalid.
    • typstyle --check no longer changes the file content.
    • Other minor improvements.

v0.12.12 - [2024-12-16]

No changes. We failed to publish the previous release because of the ci issue.

v0.12.11 - [2024-12-16]

Packaging: We've split typstyle crate into two independent crates: typstyle and typstyle-core. typstyle is the CLI tool, and typstyle-core is the core library. The npm package is now typstyle-core, typstyle on npm will be deprecated in the future.

  • Fix: // @typstyle off not working in certain cases. See #182
  • Feature: dot chain formatting is more smart now. We will only break dot chain into multiple lines if it is long enough or complex enough. For example, the following result is generated by typstyle previously:
#{
  cetz
    .draw
    .group({
      cetz.draw.translate(node.pos.xyz)
      for (i, extrude) in node.extrude.enumerate() {
        cetz
          .draw
          .set-style(
            fill: if i == 0 { node.fill },
            stroke: node.stroke,
          )
        (node.shape)(node, extrude)
      }
    })
}

Now it will be formatted as following. This is more readable and compact:

#{
  cetz.draw.group({
    cetz.draw.translate(node.pos.xyz)
    for (i, extrude) in node.extrude.enumerate() {
      cetz.draw.set-style(
        fill: if i == 0 { node.fill },
        stroke: node.stroke,
      )
      (node.shape)(node, extrude)
    }
  })
}

v0.12.10 - [2024-12-12]

  • Fix: musl build is now statically linked. This fixes the issue that the musl build doesn't work on systems other than alpine.
  • Typstyle now break content blocks into multiple lines if they have leading spaces and trailing spaces.

For example, the following code is not formattable by typstyle previously:

#{
  let res = if true [ The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines. ] else [ The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines. ]
}

Now it will be formatted as:

#{
  let res = if true [
    The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines.
  ] else [
    The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines.
  ]
}

v0.12.9 - [2024-12-08]

  • Typstyle no longer force single arg function call to be in a single line. Instead, it is determined in a smarter way. And this fixes #143.
  • Typstyle will always add newline at the end of the file. Previously, it only adds newline when it already exists.

v0.12.8 - [2024-12-07]

  • Typstyle will format binary expressions as operator chains. Parentheses are added if necessary.
  • Formatting chains with commen...
Read more

v0.13.4

30 Apr 17:49
v0.13.4
Compare
Choose a tag to compare

Changelog

v0.13.4 - [2025-04-30]

  • Feature: typstyle cli now enables import sorting by default. You can disable it with --no-reorder-import-items flag.

  • Feature: typstyle now supports --wrap-text flag to wrap texts in the markup. It is considered as experimental and may not work in all cases. Please report any issues you encounter.

    For example, this code:

    Let's say you have a long text that needs to be wrapped in the markup. This is a very long sentence that needs to be wrapped in the markup. It should be wrapped in the markup.

    Will be formatted as following when column width is 80 and --wrap-text is enabled:

    Let's say you have a long text that needs to be wrapped in the markup. This is a
    very long sentence that needs to be wrapped in the markup. It should be wrapped
    in the markup.
  • Feature: typstyle now tries to align &s in math equations, even if the cells are multiline. Currently it it works in most cases, except the following:

    • Has multiline Str or Raw descendants.
    • Not following a linebreak when in MathDelimited or Args.
    • Across args of functions such as cases.

    For example, this code:

    $
    F_n &= sum_(i=1)^n i^2 & n > 0 \
    a &< b+1 & forall b < 1
    $

    Will be formatted as:

    $
      F_n & = sum_(i=1)^n i^2 &        n > 0 \
        a & < b+1             & forall b < 1 \
    $
  • Feature: typstyle now generate more compact result when formatting complex function calls. Similar to what rustfmt does, when the only argument is combinable, it will be put in the same line as the function call. When the last argument is blocky, it will also be put in the same line if possible.

    For example, this code:

    #figure(
      fletcher.diagram(
        node-outset: .5em,
        node-stroke: .075em,
    
        node(
          (+1,0,),
          [variable],
          radius: 3em,
        ), // test
      ))

    Will be formatted as:

    #figure(fletcher.diagram(
      node-outset: .5em,
      node-stroke: .075em,
    
      node((+1, 0), [variable], radius: 3em), // test
    ))

    For another example, this code:

    #set page(
      margin: 0.5in,
      footer: context {
        if counter(page).display() == "2" {
          [test]
        } else {
          []
        }
      }
    )

    Will be formatted as:

    #set page(margin: 0.5in, footer: context {
      if counter(page).display() == "2" {
        [test]
      } else {
        []
      }
    })

    Due to the limitations of the currently used pretty engine, there is still room for improvement in some cases.

v0.13.3 - [2025-04-10]

  • Feature: Unified equation layout and removed indent for non-block equations
    • Non-block equations are no longer indented, which works well in most reasonable cases
    • Nodes with multiline comments are now treated as multiline
    • Improved comment attachment mechanism
  • Fix: Improved handling of comments directly in equations and spaces in math
    • Correctly handles in-equation comments before and after Math
    • Fixed infinite spaces added before // in math
    • Fixed extra indent of array args in math
    • Optimized spaces handling in MathAttach and MathRoot
  • Fix: Addressed list layout issues
    • Fixed indent and grouping issues in list layouts
    • Fixed missing separators in list layouts mixed with comments

v0.13.2 - [2025-03-28]

  • Feature: Typstyle can format code in markup lines now. Linebreaks are suppressed inside to ensure compact layout.
  • Feature: Typstyle can format math equations with comments and hashes now. Previously they are skipped.
  • Feature: Improved formatting of math delimited. Linebreaks are kept as is.
  • Experimental feature: Typstyle CLI will sort import items in a single import statement if --reorder-import-items is passed. It would be enabled by default in the future.
  • Added a 3rd-party typstyle-action maintained by @grayespinoza.

v0.13.1 - [2025-03-20]

  • Bump to typst v0.13.1
  • Typstyle now uses braces ({}) instead of parens (()) when the closure body is not a chainable binary expression
#fun(() => {
  aaa
})
instead of
#fun(() => (
  aaa
))
  • Fix mis-format when linebreak \ appears at the end of a inline math equation.
  • Fix mis-format when line comment appears in a multiline import statement.

v0.13.0 - [2025-02-22]

  • Bump to typst v0.13.0
  • Regression: In typst v0.13.0, PR #5310 changes the parsing behavior of comments when it presenting in list, enum and term list. In this verison, the indent level of the comment in list, enum and term list determined by the next item, not the previous item. For example,
- Fruit
  - Apple
  - Banana
  // - Orange
- Vegetable
  - Carrot
  - Tomato

will be formatted as this in this version. Note that the // - Orange is misindented. It is indented to the same level as - Vegetable. It works perfectly in previous versions. So if you want to keep the old behavior, please keep using typstyle v0.12.x at this moment.

- Fruit
  - Apple
  - Banana
// - Orange
- Vegetable
  - Carrot
  - Tomato

v0.12.15 - [2025-02-16]

  • Feat: add --tab-width cli option to set the number of spaces for indentation. The default value is 2.
  • Fix: typstyle-cli now outputs the original source when the input syntax is erroneous.
  • Fix: issues with list/enum/term item indent and linebreak with comments are fixed. Now linebreaks in items are preserved. Items in content blocks will be surrounded with linebreaks when necessary (also to avoid ambiguity).

For example, the code

+
  + xyz

-
  xyz

- //foo
  - xyz
  //bar

/ 4:
  // 4
  / 44: // 44
    444

was incorrectly formatted to

+ + xyz

- xyz

- //foo
- xyz
  //bar

/ 4: // 4
  / 44: // 44
  444

Now it is correctly unchanged.

And

#{
  [- single]
  [- indented
  - less
  ]
  [- indented
   - same
  - then less
   - then same
  ]
  [- indented
    - more
   - then same
  - then less
  ]
}

will be correctly formatted to

#{
  [- single]
  [
    - indented
    - less
  ]
  [
    - indented
    - same
    - then less
      - then same
  ]
  [
    - indented
      - more
    - then same
    - then less
  ]
}

v0.12.14 - [2024-12-27]

  • Fix: typstyle-cli previously add an extra newline at the end of the file. Now it is fixed.
  • Fix: typstyle now correctly strip leading spaces in markup
  • Feat: typstyle-core now has very basic support for range formatting.

v0.12.13 - [2024-12-21]

  • Fix: typstyle previously incorrectly remove comments in math equations. Now it is fixed.
  • Cli:
    • typstyle now reports error when the input file is invalid.
    • typstyle --check no longer changes the file content.
    • Other minor improvements.

v0.12.12 - [2024-12-16]

No changes. We failed to publish the previous release because of the ci issue.

v0.12.11 - [2024-12-16]

Packaging: We've split typstyle crate into two independent crates: typstyle and typstyle-core. typstyle is the CLI tool, and typstyle-core is the core library. The npm package is now typstyle-core, typstyle on npm will be deprecated in the future.

  • Fix: // @typstyle off not working in certain cases. See #182
  • Feature: dot chain formatting is more smart now. We will only break dot chain into multiple lines if it is long enough or complex enough. For example, the following result is generated by typstyle previously:
#{
  cetz
    .draw
    .group({
      cetz.draw.translate(node.pos.xyz)
      for (i, extrude) in node.extrude.enumerate() {
        cetz
          .draw
          .set-style(
            fill: if i == 0 { node.fill },
            stroke: node.stroke,
          )
        (node.shape)(node, extrude)
      }
    })
}

Now it will be formatted as following. This is more readable and compact:

#{
  cetz.draw.group({
    cetz.draw.translate(node.pos.xyz)
    for (i, extrude) in node.extrude.enumerate() {
      cetz.draw.set-style(
        fill: if i == 0 { node.fill },
        stroke: node.stroke,
      )
      (node.shape)(node, extrude)
    }
  })
}

v0.12.10 - [2024-12-12]

  • Fix: musl build is now statically linked. This fixes the issue that the musl build doesn't work on systems other than alpine.
  • Typstyle now break content blocks into multiple lines if they have leading spaces and trailing spaces.

For example, the following code is not formattable by typstyle previously:

#{
  let res = if true [ The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines. ] else [ The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines. ]
}

Now it will be formatted as:

#{
  let res = if true [
    The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines.
  ] else [
    The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines.
  ]
}

v0.12.9 - [2024-12-08]

  • Typstyle no longer force single arg function call to be in a single line. Instead, it is determined in a smarter way. And this fixes #143.
  • Typstyle will always add newline at the end of the file. Previously, it only adds newline when it already exists.

v0.12.8 - [2024-12-07]

  • Typstyle will format binary expressions as operator chains. Parentheses are added if necessary.
  • Formatting chains with comments is supported now. This is the last piece of formatting with comments.
  • Dot chains in markup with parentheses will be broken into multiple lines, if the it contains at least two dots and one function calls.

For example, [the following code](https:/...

Read more

v0.13.3

10 Apr 15:29
v0.13.3
Compare
Choose a tag to compare

Changelog

v0.13.3 - [2025-04-10]

  • Feature: Unified equation layout and removed indent for non-block equations
    • Non-block equations are no longer indented, which works well in most reasonable cases
    • Nodes with multiline comments are now treated as multiline
    • Improved comment attachment mechanism
  • Fix: Improved handling of comments directly in equations and spaces in math
    • Correctly handles in-equation comments before and after Math
    • Fixed infinite spaces added before // in math
    • Fixed extra indent of array args in math
    • Optimized spaces handling in MathAttach and MathRoot
  • Fix: Addressed list layout issues
    • Fixed indent and grouping issues in list layouts
    • Fixed missing separators in list layouts mixed with comments

v0.13.2 - [2025-03-28]

  • Feature: Typstyle can format code in markup lines now. Linebreaks are suppressed inside to ensure compact layout.
  • Feature: Typstyle can format math equations with comments and hashes now. Previously they are skipped.
  • Feature: Improved formatting of math delimited. Linebreaks are kept as is.
  • Experimental feature: Typstyle CLI will sort import items in a single import statement if --reorder-import-items is passed. It would be enabled by default in the future.
  • Added a 3rd-party typstyle-action maintained by @grayespinoza.

v0.13.1 - [2025-03-20]

  • Bump to typst v0.13.1
  • Typstyle now uses braces ({}) instead of parens (()) when the closure body is not a chainable binary expression
#fun(() => {
  aaa
})
instead of
#fun(() => (
  aaa
))
  • Fix mis-format when linebreak \ appears at the end of a inline math equation.
  • Fix mis-format when line comment appears in a multiline import statement.

v0.13.0 - [2025-02-22]

  • Bump to typst v0.13.0
  • Regression: In typst v0.13.0, PR #5310 changes the parsing behavior of comments when it presenting in list, enum and term list. In this verison, the indent level of the comment in list, enum and term list determined by the next item, not the previous item. For example,
- Fruit
  - Apple
  - Banana
  // - Orange
- Vegetable
  - Carrot
  - Tomato

will be formatted as this in this version. Note that the // - Orange is misindented. It is indented to the same level as - Vegetable. It works perfectly in previous versions. So if you want to keep the old behavior, please keep using typstyle v0.12.x at this moment.

- Fruit
  - Apple
  - Banana
// - Orange
- Vegetable
  - Carrot
  - Tomato

v0.12.15 - [2025-02-16]

  • Feat: add --tab-width cli option to set the number of spaces for indentation. The default value is 2.
  • Fix: typstyle-cli now outputs the original source when the input syntax is erroneous.
  • Fix: issues with list/enum/term item indent and linebreak with comments are fixed. Now linebreaks in items are preserved. Items in content blocks will be surrounded with linebreaks when necessary (also to avoid ambiguity).

For example, the code

+
  + xyz

-
  xyz

- //foo
  - xyz
  //bar

/ 4:
  // 4
  / 44: // 44
    444

was incorrectly formatted to

+ + xyz

- xyz

- //foo
- xyz
  //bar

/ 4: // 4
  / 44: // 44
  444

Now it is correctly unchanged.

And

#{
  [- single]
  [- indented
  - less
  ]
  [- indented
   - same
  - then less
   - then same
  ]
  [- indented
    - more
   - then same
  - then less
  ]
}

will be correctly formatted to

#{
  [- single]
  [
    - indented
    - less
  ]
  [
    - indented
    - same
    - then less
      - then same
  ]
  [
    - indented
      - more
    - then same
    - then less
  ]
}

v0.12.14 - [2024-12-27]

  • Fix: typstyle-cli previously add an extra newline at the end of the file. Now it is fixed.
  • Fix: typstyle now correctly strip leading spaces in markup
  • Feat: typstyle-core now has very basic support for range formatting.

v0.12.13 - [2024-12-21]

  • Fix: typstyle previously incorrectly remove comments in math equations. Now it is fixed.
  • Cli:
    • typstyle now reports error when the input file is invalid.
    • typstyle --check no longer changes the file content.
    • Other minor improvements.

v0.12.12 - [2024-12-16]

No changes. We failed to publish the previous release because of the ci issue.

v0.12.11 - [2024-12-16]

Packaging: We've split typstyle crate into two independent crates: typstyle and typstyle-core. typstyle is the CLI tool, and typstyle-core is the core library. The npm package is now typstyle-core, typstyle on npm will be deprecated in the future.

  • Fix: // @typstyle off not working in certain cases. See #182
  • Feature: dot chain formatting is more smart now. We will only break dot chain into multiple lines if it is long enough or complex enough. For example, the following result is generated by typstyle previously:
#{
  cetz
    .draw
    .group({
      cetz.draw.translate(node.pos.xyz)
      for (i, extrude) in node.extrude.enumerate() {
        cetz
          .draw
          .set-style(
            fill: if i == 0 { node.fill },
            stroke: node.stroke,
          )
        (node.shape)(node, extrude)
      }
    })
}

Now it will be formatted as following. This is more readable and compact:

#{
  cetz.draw.group({
    cetz.draw.translate(node.pos.xyz)
    for (i, extrude) in node.extrude.enumerate() {
      cetz.draw.set-style(
        fill: if i == 0 { node.fill },
        stroke: node.stroke,
      )
      (node.shape)(node, extrude)
    }
  })
}

v0.12.10 - [2024-12-12]

  • Fix: musl build is now statically linked. This fixes the issue that the musl build doesn't work on systems other than alpine.
  • Typstyle now break content blocks into multiple lines if they have leading spaces and trailing spaces.

For example, the following code is not formattable by typstyle previously:

#{
  let res = if true [ The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines. ] else [ The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines. ]
}

Now it will be formatted as:

#{
  let res = if true [
    The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines.
  ] else [
    The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines.
  ]
}

v0.12.9 - [2024-12-08]

  • Typstyle no longer force single arg function call to be in a single line. Instead, it is determined in a smarter way. And this fixes #143.
  • Typstyle will always add newline at the end of the file. Previously, it only adds newline when it already exists.

v0.12.8 - [2024-12-07]

  • Typstyle will format binary expressions as operator chains. Parentheses are added if necessary.
  • Formatting chains with comments is supported now. This is the last piece of formatting with comments.
  • Dot chains in markup with parentheses will be broken into multiple lines, if the it contains at least two dots and one function calls.

For example, the following code:

#let _is_block(e,fn)=fn==heading or (fn==math.equation and e.block) or (fn==raw and e.has("block") and e.block) or fn==figure or fn==block or fn==list.item or fn==enum.item or fn==table or fn==grid or fn==align or (fn==quote and e.has("block") and e.block)

Will be formatted as this in previous versions:

#let _is_block(e, fn) = (
  fn == heading or (fn == math.equation and e.block) or (
    fn == raw and e.has("block") and e.block
  ) or fn == figure or fn == block or fn == list.item or fn == enum.item or fn == table or fn == grid or fn == align or (
    fn == quote and e.has("block") and e.block
  )
)

Now it will be formatted as:

#let _is_block(e, fn) = (
  fn == heading
    or (fn == math.equation and e.block)
    or (fn == raw and e.has("block") and e.block)
    or fn == figure
    or fn == block
    or fn == list.item
    or fn == enum.item
    or fn == table
    or fn == grid
    or fn == align
    or (fn == quote and e.has("block") and e.block)
)

v0.12.7 - [2024-12-04]

  • Dot chain related improvement:
    • Previously if the last item of a dot chain is a function call, typstyle doesn't indent it correctly. Now it is fixed.
    • Previously typstyle formats function calls in dot chains in a very conversative way. Now it is the same as normal function calls.
  • Function calls with comments are made formattable.

For example, the following code is not formattable by typstyle previously:

#{
  let x = f(
  cetz.draw.super-long-name.line(
    start: (0, 0),
    end: (1, 1),      // note
  ) // my comment
)
}

Now it will be formatted as:

#{
  let x = f(
    cetz
      .draw
      .super-long-name
      .line(
        start: (0, 0),
        end: (1, 1), // note
      ), // my comment
  )
}

v0.12.6 - [2024-12-02]

  • Parenthesized expressions with comments can be formatted by typstyle now.
  • Closure with comments can be formatted by typstyle now.
  • Typstyle will removes unnecessary parentheses if the inner expression is literal, array, dict, destructuring, block, or pattern. For safety, parens around idents are kept.
  • Destructuring and params with comments are no longer forced to fold into one line.

v0.12.5 - [2024-11-29]

  • Typstyle can format comments appears in most places. Previously it simply gives up when it encounters comments in these places. Now it can format them correctly.

For example, this code:

#let conf(
  title: none,   //comments
  authors:      (),
  abstract: [],
  lang: "zh",   // language
  doctype: "book",  //comments
  doc  // my docs
) = {
    d...
Read more

v0.13.2

28 Mar 15:19
v0.13.2
Compare
Choose a tag to compare

Changelog

v0.13.2 - [2025-03-28]

  • Feature: Typstyle can format code in markup lines now. Linebreaks are suppressed inside to ensure compact layout.
  • Feature: Typstyle can format math equations with comments and hashes now. Previously they are skipped.
  • Feature: Improved formatting of math delimited. Linebreaks are kept as is.
  • Experimental feature: Typstyle CLI will sort import items in a single import statement if --reorder-import-items is passed. It would be enabled by default in the future.
  • Added a 3rd-party typstyle-action maintained by @grayespinoza.

v0.13.1 - [2025-03-20]

  • Bump to typst v0.13.1
  • Typstyle now uses braces ({}) instead of parens (()) when the closure body is not a chainable binary expression
#fun(() => {
  aaa
})
instead of
#fun(() => (
  aaa
))
  • Fix mis-format when linebreak \ appears at the end of a inline math equation.
  • Fix mis-format when line comment appears in a multiline import statement.

v0.13.0 - [2025-02-22]

  • Bump to typst v0.13.0
  • Regression: In typst v0.13.0, PR #5310 changes the parsing behavior of comments when it presenting in list, enum and term list. In this verison, the indent level of the comment in list, enum and term list determined by the next item, not the previous item. For example,
- Fruit
  - Apple
  - Banana
  // - Orange
- Vegetable
  - Carrot
  - Tomato

will be formatted as this in this version. Note that the // - Orange is misindented. It is indented to the same level as - Vegetable. It works perfectly in previous versions. So if you want to keep the old behavior, please keep using typstyle v0.12.x at this moment.

- Fruit
  - Apple
  - Banana
// - Orange
- Vegetable
  - Carrot
  - Tomato

v0.12.15 - [2025-02-16]

  • Feat: add --tab-width cli option to set the number of spaces for indentation. The default value is 2.
  • Fix: typstyle-cli now outputs the original source when the input syntax is erroneous.
  • Fix: issues with list/enum/term item indent and linebreak with comments are fixed. Now linebreaks in items are preserved. Items in content blocks will be surrounded with linebreaks when necessary (also to avoid ambiguity).

For example, the code

+
  + xyz

-
  xyz

- //foo
  - xyz
  //bar

/ 4:
  // 4
  / 44: // 44
    444

was incorrectly formatted to

+ + xyz

- xyz

- //foo
- xyz
  //bar

/ 4: // 4
  / 44: // 44
  444

Now it is correctly unchanged.

And

#{
  [- single]
  [- indented
  - less
  ]
  [- indented
   - same
  - then less
   - then same
  ]
  [- indented
    - more
   - then same
  - then less
  ]
}

will be correctly formatted to

#{
  [- single]
  [
    - indented
    - less
  ]
  [
    - indented
    - same
    - then less
      - then same
  ]
  [
    - indented
      - more
    - then same
    - then less
  ]
}

v0.12.14 - [2024-12-27]

  • Fix: typstyle-cli previously add an extra newline at the end of the file. Now it is fixed.
  • Fix: typstyle now correctly strip leading spaces in markup
  • Feat: typstyle-core now has very basic support for range formatting.

v0.12.13 - [2024-12-21]

  • Fix: typstyle previously incorrectly remove comments in math equations. Now it is fixed.
  • Cli:
    • typstyle now reports error when the input file is invalid.
    • typstyle --check no longer changes the file content.
    • Other minor improvements.

v0.12.12 - [2024-12-16]

No changes. We failed to publish the previous release because of the ci issue.

v0.12.11 - [2024-12-16]

Packaging: We've split typstyle crate into two independent crates: typstyle and typstyle-core. typstyle is the CLI tool, and typstyle-core is the core library. The npm package is now typstyle-core, typstyle on npm will be deprecated in the future.

  • Fix: // @typstyle off not working in certain cases. See #182
  • Feature: dot chain formatting is more smart now. We will only break dot chain into multiple lines if it is long enough or complex enough. For example, the following result is generated by typstyle previously:
#{
  cetz
    .draw
    .group({
      cetz.draw.translate(node.pos.xyz)
      for (i, extrude) in node.extrude.enumerate() {
        cetz
          .draw
          .set-style(
            fill: if i == 0 { node.fill },
            stroke: node.stroke,
          )
        (node.shape)(node, extrude)
      }
    })
}

Now it will be formatted as following. This is more readable and compact:

#{
  cetz.draw.group({
    cetz.draw.translate(node.pos.xyz)
    for (i, extrude) in node.extrude.enumerate() {
      cetz.draw.set-style(
        fill: if i == 0 { node.fill },
        stroke: node.stroke,
      )
      (node.shape)(node, extrude)
    }
  })
}

v0.12.10 - [2024-12-12]

  • Fix: musl build is now statically linked. This fixes the issue that the musl build doesn't work on systems other than alpine.
  • Typstyle now break content blocks into multiple lines if they have leading spaces and trailing spaces.

For example, the following code is not formattable by typstyle previously:

#{
  let res = if true [ The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines. ] else [ The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines. ]
}

Now it will be formatted as:

#{
  let res = if true [
    The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines.
  ] else [
    The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines.
  ]
}

v0.12.9 - [2024-12-08]

  • Typstyle no longer force single arg function call to be in a single line. Instead, it is determined in a smarter way. And this fixes #143.
  • Typstyle will always add newline at the end of the file. Previously, it only adds newline when it already exists.

v0.12.8 - [2024-12-07]

  • Typstyle will format binary expressions as operator chains. Parentheses are added if necessary.
  • Formatting chains with comments is supported now. This is the last piece of formatting with comments.
  • Dot chains in markup with parentheses will be broken into multiple lines, if the it contains at least two dots and one function calls.

For example, the following code:

#let _is_block(e,fn)=fn==heading or (fn==math.equation and e.block) or (fn==raw and e.has("block") and e.block) or fn==figure or fn==block or fn==list.item or fn==enum.item or fn==table or fn==grid or fn==align or (fn==quote and e.has("block") and e.block)

Will be formatted as this in previous versions:

#let _is_block(e, fn) = (
  fn == heading or (fn == math.equation and e.block) or (
    fn == raw and e.has("block") and e.block
  ) or fn == figure or fn == block or fn == list.item or fn == enum.item or fn == table or fn == grid or fn == align or (
    fn == quote and e.has("block") and e.block
  )
)

Now it will be formatted as:

#let _is_block(e, fn) = (
  fn == heading
    or (fn == math.equation and e.block)
    or (fn == raw and e.has("block") and e.block)
    or fn == figure
    or fn == block
    or fn == list.item
    or fn == enum.item
    or fn == table
    or fn == grid
    or fn == align
    or (fn == quote and e.has("block") and e.block)
)

v0.12.7 - [2024-12-04]

  • Dot chain related improvement:
    • Previously if the last item of a dot chain is a function call, typstyle doesn't indent it correctly. Now it is fixed.
    • Previously typstyle formats function calls in dot chains in a very conversative way. Now it is the same as normal function calls.
  • Function calls with comments are made formattable.

For example, the following code is not formattable by typstyle previously:

#{
  let x = f(
  cetz.draw.super-long-name.line(
    start: (0, 0),
    end: (1, 1),      // note
  ) // my comment
)
}

Now it will be formatted as:

#{
  let x = f(
    cetz
      .draw
      .super-long-name
      .line(
        start: (0, 0),
        end: (1, 1), // note
      ), // my comment
  )
}

v0.12.6 - [2024-12-02]

  • Parenthesized expressions with comments can be formatted by typstyle now.
  • Closure with comments can be formatted by typstyle now.
  • Typstyle will removes unnecessary parentheses if the inner expression is literal, array, dict, destructuring, block, or pattern. For safety, parens around idents are kept.
  • Destructuring and params with comments are no longer forced to fold into one line.

v0.12.5 - [2024-11-29]

  • Typstyle can format comments appears in most places. Previously it simply gives up when it encounters comments in these places. Now it can format them correctly.

For example, this code:

#let conf(
  title: none,   //comments
  authors:      (),
  abstract: [],
  lang: "zh",   // language
  doctype: "book",  //comments
  doc  // my docs
) = {
    doc }

Previously typstyle will not format it. Now it will be formatted as:

#let conf(
  title: none, //comments
  authors: (),
  abstract: [],
  lang: "zh", // language
  doctype: "book", //comments
  doc, // my docs
) = {
  doc
}

However, there are still some limitations. For more information, see Limitation.

  • Fix typstyle previously would format parenthesized patterns incorrectly into none. Now it is fixed.

v0.12.4 - [2024-11-26]

  • Performance improvement(#158, #159 by @QuadnucYard): Typstyle now becomes 10-100x faster than before. Previously formatting tablex source code takes ~500ms, but now it only takes less than 5ms.

v0.12.3 - [20...

Read more

v0.13.1

20 Mar 16:22
v0.13.1
Compare
Choose a tag to compare

Changelog

v0.13.1 - [2025-03-20]

  • Bump to typst v0.13.1
  • Typstyle now uses braces ({}) instead of parens (()) when the closure body is not a chainable binary expression
#fun(() => {
  aaa
})
instead of
#fun(() => (
  aaa
))
  • Fix mis-format when linebreak \ appears at the end of a inline math equation.
  • Fix mis-format when line comment appears in a multiline import statement.

v0.13.0 - [2025-02-22]

  • Bump to typst v0.13.0
  • Regression: In typst v0.13.0, PR #5310 changes the parsing behavior of comments when it presenting in list, enum and term list. In this verison, the indent level of the comment in list, enum and term list determined by the next item, not the previous item. For example,
- Fruit
  - Apple
  - Banana
  // - Orange
- Vegetable
  - Carrot
  - Tomato

will be formatted as this in this version. Note that the // - Orange is misindented. It is indented to the same level as - Vegetable. It works perfectly in previous versions. So if you want to keep the old behavior, please keep using typstyle v0.12.x at this moment.

- Fruit
  - Apple
  - Banana
// - Orange
- Vegetable
  - Carrot
  - Tomato

v0.12.15 - [2025-02-16]

  • Feat: add --tab-width cli option to set the number of spaces for indentation. The default value is 2.
  • Fix: typstyle-cli now outputs the original source when the input syntax is erroneous.
  • Fix: issues with list/enum/term item indent and linebreak with comments are fixed. Now linebreaks in items are preserved. Items in content blocks will be surrounded with linebreaks when necessary (also to avoid ambiguity).

For example, the code

+
  + xyz

-
  xyz

- //foo
  - xyz
  //bar

/ 4:
  // 4
  / 44: // 44
    444

was incorrectly formatted to

+ + xyz

- xyz

- //foo
- xyz
  //bar

/ 4: // 4
  / 44: // 44
  444

Now it is correctly unchanged.

And

#{
  [- single]
  [- indented
  - less
  ]
  [- indented
   - same
  - then less
   - then same
  ]
  [- indented
    - more
   - then same
  - then less
  ]
}

will be correctly formatted to

#{
  [- single]
  [
    - indented
    - less
  ]
  [
    - indented
    - same
    - then less
      - then same
  ]
  [
    - indented
      - more
    - then same
    - then less
  ]
}

v0.12.14 - [2024-12-27]

  • Fix: typstyle-cli previously add an extra newline at the end of the file. Now it is fixed.
  • Fix: typstyle now correctly strip leading spaces in markup
  • Feat: typstyle-core now has very basic support for range formatting.

v0.12.13 - [2024-12-21]

  • Fix: typstyle previously incorrectly remove comments in math equations. Now it is fixed.
  • Cli:
    • typstyle now reports error when the input file is invalid.
    • typstyle --check no longer changes the file content.
    • Other minor improvements.

v0.12.12 - [2024-12-16]

No changes. We failed to publish the previous release because of the ci issue.

v0.12.11 - [2024-12-16]

Packaging: We've split typstyle crate into two independent crates: typstyle and typstyle-core. typstyle is the CLI tool, and typstyle-core is the core library. The npm package is now typstyle-core, typstyle on npm will be deprecated in the future.

  • Fix: // @typstyle off not working in certain cases. See #182
  • Feature: dot chain formatting is more smart now. We will only break dot chain into multiple lines if it is long enough or complex enough. For example, the following result is generated by typstyle previously:
#{
  cetz
    .draw
    .group({
      cetz.draw.translate(node.pos.xyz)
      for (i, extrude) in node.extrude.enumerate() {
        cetz
          .draw
          .set-style(
            fill: if i == 0 { node.fill },
            stroke: node.stroke,
          )
        (node.shape)(node, extrude)
      }
    })
}

Now it will be formatted as following. This is more readable and compact:

#{
  cetz.draw.group({
    cetz.draw.translate(node.pos.xyz)
    for (i, extrude) in node.extrude.enumerate() {
      cetz.draw.set-style(
        fill: if i == 0 { node.fill },
        stroke: node.stroke,
      )
      (node.shape)(node, extrude)
    }
  })
}

v0.12.10 - [2024-12-12]

  • Fix: musl build is now statically linked. This fixes the issue that the musl build doesn't work on systems other than alpine.
  • Typstyle now break content blocks into multiple lines if they have leading spaces and trailing spaces.

For example, the following code is not formattable by typstyle previously:

#{
  let res = if true [ The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines. ] else [ The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines. ]
}

Now it will be formatted as:

#{
  let res = if true [
    The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines.
  ] else [
    The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines.
  ]
}

v0.12.9 - [2024-12-08]

  • Typstyle no longer force single arg function call to be in a single line. Instead, it is determined in a smarter way. And this fixes #143.
  • Typstyle will always add newline at the end of the file. Previously, it only adds newline when it already exists.

v0.12.8 - [2024-12-07]

  • Typstyle will format binary expressions as operator chains. Parentheses are added if necessary.
  • Formatting chains with comments is supported now. This is the last piece of formatting with comments.
  • Dot chains in markup with parentheses will be broken into multiple lines, if the it contains at least two dots and one function calls.

For example, the following code:

#let _is_block(e,fn)=fn==heading or (fn==math.equation and e.block) or (fn==raw and e.has("block") and e.block) or fn==figure or fn==block or fn==list.item or fn==enum.item or fn==table or fn==grid or fn==align or (fn==quote and e.has("block") and e.block)

Will be formatted as this in previous versions:

#let _is_block(e, fn) = (
  fn == heading or (fn == math.equation and e.block) or (
    fn == raw and e.has("block") and e.block
  ) or fn == figure or fn == block or fn == list.item or fn == enum.item or fn == table or fn == grid or fn == align or (
    fn == quote and e.has("block") and e.block
  )
)

Now it will be formatted as:

#let _is_block(e, fn) = (
  fn == heading
    or (fn == math.equation and e.block)
    or (fn == raw and e.has("block") and e.block)
    or fn == figure
    or fn == block
    or fn == list.item
    or fn == enum.item
    or fn == table
    or fn == grid
    or fn == align
    or (fn == quote and e.has("block") and e.block)
)

v0.12.7 - [2024-12-04]

  • Dot chain related improvement:
    • Previously if the last item of a dot chain is a function call, typstyle doesn't indent it correctly. Now it is fixed.
    • Previously typstyle formats function calls in dot chains in a very conversative way. Now it is the same as normal function calls.
  • Function calls with comments are made formattable.

For example, the following code is not formattable by typstyle previously:

#{
  let x = f(
  cetz.draw.super-long-name.line(
    start: (0, 0),
    end: (1, 1),      // note
  ) // my comment
)
}

Now it will be formatted as:

#{
  let x = f(
    cetz
      .draw
      .super-long-name
      .line(
        start: (0, 0),
        end: (1, 1), // note
      ), // my comment
  )
}

v0.12.6 - [2024-12-02]

  • Parenthesized expressions with comments can be formatted by typstyle now.
  • Closure with comments can be formatted by typstyle now.
  • Typstyle will removes unnecessary parentheses if the inner expression is literal, array, dict, destructuring, block, or pattern. For safety, parens around idents are kept.
  • Destructuring and params with comments are no longer forced to fold into one line.

v0.12.5 - [2024-11-29]

  • Typstyle can format comments appears in most places. Previously it simply gives up when it encounters comments in these places. Now it can format them correctly.

For example, this code:

#let conf(
  title: none,   //comments
  authors:      (),
  abstract: [],
  lang: "zh",   // language
  doctype: "book",  //comments
  doc  // my docs
) = {
    doc }

Previously typstyle will not format it. Now it will be formatted as:

#let conf(
  title: none, //comments
  authors: (),
  abstract: [],
  lang: "zh", // language
  doctype: "book", //comments
  doc, // my docs
) = {
  doc
}

However, there are still some limitations. For more information, see Limitation.

  • Fix typstyle previously would format parenthesized patterns incorrectly into none. Now it is fixed.

v0.12.4 - [2024-11-26]

  • Performance improvement(#158, #159 by @QuadnucYard): Typstyle now becomes 10-100x faster than before. Previously formatting tablex source code takes ~500ms, but now it only takes less than 5ms.

v0.12.3 - [2024-11-24]

  • Fix doc test failure that prevents nixpkgs from building typstyle.

v0.12.2 - [2024-11-23]

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:

#{
  let x = if true { 1 } else { 2 }
}

Instead of:

#{
  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 w...
Read more

v0.13.0

22 Feb 06:10
v0.13.0
43ff4e3
Compare
Choose a tag to compare

Changelog

v0.13.0 - [2025-02-22]

  • Bump to typst v0.13.0
  • Regression: In typst v0.13.0, PR #5310 changes the parsing behavior of comments when it presenting in list, enum and term list. In this verison, the indent level of the comment in list, enum and term list determined by the next item, not the previous item. For example,
- Fruit
  - Apple
  - Banana
  // - Orange
- Vegetable
  - Carrot
  - Tomato

will be formatted as this in this version. Note that the // - Orange is misindented. It is indented to the same level as - Vegetable. It works perfectly in previous versions. So if you want to keep the old behavior, please keep using typstyle v0.12.x at this moment.

- Fruit
  - Apple
  - Banana
// - Orange
- Vegetable
  - Carrot
  - Tomato

v0.12.15 - [2025-02-16]

  • Feat: add --tab-width cli option to set the number of spaces for indentation. The default value is 2.
  • Fix: typstyle-cli now outputs the original source when the input syntax is erroneous.
  • Fix: issues with list/enum/term item indent and linebreak with comments are fixed. Now linebreaks in items are preserved. Items in content blocks will be surrounded with linebreaks when necessary (also to avoid ambiguity).

For example, the code

+
  + xyz

-
  xyz

- //foo
  - xyz
  //bar

/ 4:
  // 4
  / 44: // 44
    444

was incorrectly formatted to

+ + xyz

- xyz

- //foo
- xyz
  //bar

/ 4: // 4
  / 44: // 44
  444

Now it is correctly unchanged.

And

#{
  [- single]
  [- indented
  - less
  ]
  [- indented
   - same
  - then less
   - then same
  ]
  [- indented
    - more
   - then same
  - then less
  ]
}

will be correctly formatted to

#{
  [- single]
  [
    - indented
    - less
  ]
  [
    - indented
    - same
    - then less
      - then same
  ]
  [
    - indented
      - more
    - then same
    - then less
  ]
}

v0.12.14 - [2024-12-27]

  • Fix: typstyle-cli previously add an extra newline at the end of the file. Now it is fixed.
  • Fix: typstyle now correctly strip leading spaces in markup
  • Feat: typstyle-core now has very basic support for range formatting.

v0.12.13 - [2024-12-21]

  • Fix: typstyle previously incorrectly remove comments in math equations. Now it is fixed.
  • Cli:
    • typstyle now reports error when the input file is invalid.
    • typstyle --check no longer changes the file content.
    • Other minor improvements.

v0.12.12 - [2024-12-16]

No changes. We failed to publish the previous release because of the ci issue.

v0.12.11 - [2024-12-16]

Packaging: We've split typstyle crate into two independent crates: typstyle and typstyle-core. typstyle is the CLI tool, and typstyle-core is the core library. The npm package is now typstyle-core, typstyle on npm will be deprecated in the future.

  • Fix: // @typstyle off not working in certain cases. See #182
  • Feature: dot chain formatting is more smart now. We will only break dot chain into multiple lines if it is long enough or complex enough. For example, the following result is generated by typstyle previously:
#{
  cetz
    .draw
    .group({
      cetz.draw.translate(node.pos.xyz)
      for (i, extrude) in node.extrude.enumerate() {
        cetz
          .draw
          .set-style(
            fill: if i == 0 { node.fill },
            stroke: node.stroke,
          )
        (node.shape)(node, extrude)
      }
    })
}

Now it will be formatted as following. This is more readable and compact:

#{
  cetz.draw.group({
    cetz.draw.translate(node.pos.xyz)
    for (i, extrude) in node.extrude.enumerate() {
      cetz.draw.set-style(
        fill: if i == 0 { node.fill },
        stroke: node.stroke,
      )
      (node.shape)(node, extrude)
    }
  })
}

v0.12.10 - [2024-12-12]

  • Fix: musl build is now statically linked. This fixes the issue that the musl build doesn't work on systems other than alpine.
  • Typstyle now break content blocks into multiple lines if they have leading spaces and trailing spaces.

For example, the following code is not formattable by typstyle previously:

#{
  let res = if true [ The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines. ] else [ The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines. ]
}

Now it will be formatted as:

#{
  let res = if true [
    The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines.
  ] else [
    The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines.
  ]
}

v0.12.9 - [2024-12-08]

  • Typstyle no longer force single arg function call to be in a single line. Instead, it is determined in a smarter way. And this fixes #143.
  • Typstyle will always add newline at the end of the file. Previously, it only adds newline when it already exists.

v0.12.8 - [2024-12-07]

  • Typstyle will format binary expressions as operator chains. Parentheses are added if necessary.
  • Formatting chains with comments is supported now. This is the last piece of formatting with comments.
  • Dot chains in markup with parentheses will be broken into multiple lines, if the it contains at least two dots and one function calls.

For example, the following code:

#let _is_block(e,fn)=fn==heading or (fn==math.equation and e.block) or (fn==raw and e.has("block") and e.block) or fn==figure or fn==block or fn==list.item or fn==enum.item or fn==table or fn==grid or fn==align or (fn==quote and e.has("block") and e.block)

Will be formatted as this in previous versions:

#let _is_block(e, fn) = (
  fn == heading or (fn == math.equation and e.block) or (
    fn == raw and e.has("block") and e.block
  ) or fn == figure or fn == block or fn == list.item or fn == enum.item or fn == table or fn == grid or fn == align or (
    fn == quote and e.has("block") and e.block
  )
)

Now it will be formatted as:

#let _is_block(e, fn) = (
  fn == heading
    or (fn == math.equation and e.block)
    or (fn == raw and e.has("block") and e.block)
    or fn == figure
    or fn == block
    or fn == list.item
    or fn == enum.item
    or fn == table
    or fn == grid
    or fn == align
    or (fn == quote and e.has("block") and e.block)
)

v0.12.7 - [2024-12-04]

  • Dot chain related improvement:
    • Previously if the last item of a dot chain is a function call, typstyle doesn't indent it correctly. Now it is fixed.
    • Previously typstyle formats function calls in dot chains in a very conversative way. Now it is the same as normal function calls.
  • Function calls with comments are made formattable.

For example, the following code is not formattable by typstyle previously:

#{
  let x = f(
  cetz.draw.super-long-name.line(
    start: (0, 0),
    end: (1, 1),      // note
  ) // my comment
)
}

Now it will be formatted as:

#{
  let x = f(
    cetz
      .draw
      .super-long-name
      .line(
        start: (0, 0),
        end: (1, 1), // note
      ), // my comment
  )
}

v0.12.6 - [2024-12-02]

  • Parenthesized expressions with comments can be formatted by typstyle now.
  • Closure with comments can be formatted by typstyle now.
  • Typstyle will removes unnecessary parentheses if the inner expression is literal, array, dict, destructuring, block, or pattern. For safety, parens around idents are kept.
  • Destructuring and params with comments are no longer forced to fold into one line.

v0.12.5 - [2024-11-29]

  • Typstyle can format comments appears in most places. Previously it simply gives up when it encounters comments in these places. Now it can format them correctly.

For example, this code:

#let conf(
  title: none,   //comments
  authors:      (),
  abstract: [],
  lang: "zh",   // language
  doctype: "book",  //comments
  doc  // my docs
) = {
    doc }

Previously typstyle will not format it. Now it will be formatted as:

#let conf(
  title: none, //comments
  authors: (),
  abstract: [],
  lang: "zh", // language
  doctype: "book", //comments
  doc, // my docs
) = {
  doc
}

However, there are still some limitations. For more information, see Limitation.

  • Fix typstyle previously would format parenthesized patterns incorrectly into none. Now it is fixed.

v0.12.4 - [2024-11-26]

  • Performance improvement(#158, #159 by @QuadnucYard): Typstyle now becomes 10-100x faster than before. Previously formatting tablex source code takes ~500ms, but now it only takes less than 5ms.

v0.12.3 - [2024-11-24]

  • Fix doc test failure that prevents nixpkgs from building typstyle.

v0.12.2 - [2024-11-23]

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:

#{
  let x = if true { 1 } else { 2 }
}

Instead of:

#{
  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:

#{
  
  
  let x = 1

  let y = 2

}

After formatting, it will become:

#{
  let x = 1

  let y = 2
}
  • Formatting block comments are now improved. Previously, leading spaces in block comments are blindly removed. Now typstyle will ke...
Read more

v0.12.15

16 Feb 14:08
v0.12.15
Compare
Choose a tag to compare

Changelog

v0.12.15 - [2025-02-16]

  • Feat: add --tab-width cli option to set the number of spaces for indentation. The default value is 2.
  • Fix: typstyle-cli now outputs the original source when the input syntax is erroneous.
  • Fix: issues with list/enum/term item indent and linebreak with comments are fixed. Now linebreaks in items are preserved. Items in content blocks will be surrounded with linebreaks when necessary (also to avoid ambiguity).

For example, the code

+
  + xyz

-
  xyz

- //foo
  - xyz
  //bar

/ 4:
  // 4
  / 44: // 44
    444

was incorrectly formatted to

+ + xyz

- xyz

- //foo
- xyz
  //bar

/ 4: // 4
  / 44: // 44
  444

Now it is correctly unchanged.

And

#{
  [- single]
  [- indented
  - less
  ]
  [- indented
   - same
  - then less
   - then same
  ]
  [- indented
    - more
   - then same
  - then less
  ]
}

will be correctly formatted to

#{
  [- single]
  [
    - indented
    - less
  ]
  [
    - indented
    - same
    - then less
      - then same
  ]
  [
    - indented
      - more
    - then same
    - then less
  ]
}

v0.12.14 - [2024-12-27]

  • Fix: typstyle-cli previously add an extra newline at the end of the file. Now it is fixed.
  • Fix: typstyle now correctly strip leading spaces in markup
  • Feat: typstyle-core now has very basic support for range formatting.

v0.12.13 - [2024-12-21]

  • Fix: typstyle previously incorrectly remove comments in math equations. Now it is fixed.
  • Cli:
    • typstyle now reports error when the input file is invalid.
    • typstyle --check no longer changes the file content.
    • Other minor improvements.

v0.12.12 - [2024-12-16]

No changes. We failed to publish the previous release because of the ci issue.

v0.12.11 - [2024-12-16]

Packaging: We've split typstyle crate into two independent crates: typstyle and typstyle-core. typstyle is the CLI tool, and typstyle-core is the core library. The npm package is now typstyle-core, typstyle on npm will be deprecated in the future.

  • Fix: // @typstyle off not working in certain cases. See #182
  • Feature: dot chain formatting is more smart now. We will only break dot chain into multiple lines if it is long enough or complex enough. For example, the following result is generated by typstyle previously:
#{
  cetz
    .draw
    .group({
      cetz.draw.translate(node.pos.xyz)
      for (i, extrude) in node.extrude.enumerate() {
        cetz
          .draw
          .set-style(
            fill: if i == 0 { node.fill },
            stroke: node.stroke,
          )
        (node.shape)(node, extrude)
      }
    })
}

Now it will be formatted as following. This is more readable and compact:

#{
  cetz.draw.group({
    cetz.draw.translate(node.pos.xyz)
    for (i, extrude) in node.extrude.enumerate() {
      cetz.draw.set-style(
        fill: if i == 0 { node.fill },
        stroke: node.stroke,
      )
      (node.shape)(node, extrude)
    }
  })
}

v0.12.10 - [2024-12-12]

  • Fix: musl build is now statically linked. This fixes the issue that the musl build doesn't work on systems other than alpine.
  • Typstyle now break content blocks into multiple lines if they have leading spaces and trailing spaces.

For example, the following code is not formattable by typstyle previously:

#{
  let res = if true [ The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines. ] else [ The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines. ]
}

Now it will be formatted as:

#{
  let res = if true [
    The Result is definitely true. And it is a very long sentence that needs to be broken into multiple lines.
  ] else [
    The Result is definitely false. And it is a very long sentence that needs to be broken into multiple lines.
  ]
}

v0.12.9 - [2024-12-08]

  • Typstyle no longer force single arg function call to be in a single line. Instead, it is determined in a smarter way. And this fixes #143.
  • Typstyle will always add newline at the end of the file. Previously, it only adds newline when it already exists.

v0.12.8 - [2024-12-07]

  • Typstyle will format binary expressions as operator chains. Parentheses are added if necessary.
  • Formatting chains with comments is supported now. This is the last piece of formatting with comments.
  • Dot chains in markup with parentheses will be broken into multiple lines, if the it contains at least two dots and one function calls.

For example, the following code:

#let _is_block(e,fn)=fn==heading or (fn==math.equation and e.block) or (fn==raw and e.has("block") and e.block) or fn==figure or fn==block or fn==list.item or fn==enum.item or fn==table or fn==grid or fn==align or (fn==quote and e.has("block") and e.block)

Will be formatted as this in previous versions:

#let _is_block(e, fn) = (
  fn == heading or (fn == math.equation and e.block) or (
    fn == raw and e.has("block") and e.block
  ) or fn == figure or fn == block or fn == list.item or fn == enum.item or fn == table or fn == grid or fn == align or (
    fn == quote and e.has("block") and e.block
  )
)

Now it will be formatted as:

#let _is_block(e, fn) = (
  fn == heading
    or (fn == math.equation and e.block)
    or (fn == raw and e.has("block") and e.block)
    or fn == figure
    or fn == block
    or fn == list.item
    or fn == enum.item
    or fn == table
    or fn == grid
    or fn == align
    or (fn == quote and e.has("block") and e.block)
)

v0.12.7 - [2024-12-04]

  • Dot chain related improvement:
    • Previously if the last item of a dot chain is a function call, typstyle doesn't indent it correctly. Now it is fixed.
    • Previously typstyle formats function calls in dot chains in a very conversative way. Now it is the same as normal function calls.
  • Function calls with comments are made formattable.

For example, the following code is not formattable by typstyle previously:

#{
  let x = f(
  cetz.draw.super-long-name.line(
    start: (0, 0),
    end: (1, 1),      // note
  ) // my comment
)
}

Now it will be formatted as:

#{
  let x = f(
    cetz
      .draw
      .super-long-name
      .line(
        start: (0, 0),
        end: (1, 1), // note
      ), // my comment
  )
}

v0.12.6 - [2024-12-02]

  • Parenthesized expressions with comments can be formatted by typstyle now.
  • Closure with comments can be formatted by typstyle now.
  • Typstyle will removes unnecessary parentheses if the inner expression is literal, array, dict, destructuring, block, or pattern. For safety, parens around idents are kept.
  • Destructuring and params with comments are no longer forced to fold into one line.

v0.12.5 - [2024-11-29]

  • Typstyle can format comments appears in most places. Previously it simply gives up when it encounters comments in these places. Now it can format them correctly.

For example, this code:

#let conf(
  title: none,   //comments
  authors:      (),
  abstract: [],
  lang: "zh",   // language
  doctype: "book",  //comments
  doc  // my docs
) = {
    doc }

Previously typstyle will not format it. Now it will be formatted as:

#let conf(
  title: none, //comments
  authors: (),
  abstract: [],
  lang: "zh", // language
  doctype: "book", //comments
  doc, // my docs
) = {
  doc
}

However, there are still some limitations. For more information, see Limitation.

  • Fix typstyle previously would format parenthesized patterns incorrectly into none. Now it is fixed.

v0.12.4 - [2024-11-26]

  • Performance improvement(#158, #159 by @QuadnucYard): Typstyle now becomes 10-100x faster than before. Previously formatting tablex source code takes ~500ms, but now it only takes less than 5ms.

v0.12.3 - [2024-11-24]

  • Fix doc test failure that prevents nixpkgs from building typstyle.

v0.12.2 - [2024-11-23]

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:

#{
  let x = if true { 1 } else { 2 }
}

Instead of:

#{
  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:

#{
  
  
  let x = 1

  let y = 2

}

After formatting, it will become:

#{
  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:

#{
  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:

#{
  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 ex...
Read more