diff --git a/Cargo.lock b/Cargo.lock index 85ae836..4cdc88b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2722,7 +2722,7 @@ checksum = "12d0f851e0a0be6291218f139b878baccd7adc93f952887e4afb0524408db64f" dependencies = [ "cfg-if", "typst", - "typst-syntax", + "typst-syntax 0.12.0", ] [[package]] @@ -3917,9 +3917,9 @@ dependencies = [ "typed-arena", "typst-assets", "typst-macros", - "typst-syntax", - "typst-timing", - "typst-utils", + "typst-syntax 0.12.0", + "typst-timing 0.12.0", + "typst-utils 0.12.0", "unicode-bidi", "unicode-math-class", "unicode-script", @@ -3971,7 +3971,7 @@ dependencies = [ "typst", "typst-assets", "typst-macros", - "typst-timing", + "typst-timing 0.12.0", "unscanny", "xmp-writer", ] @@ -3992,7 +3992,7 @@ dependencies = [ "ttf-parser", "typst", "typst-macros", - "typst-timing", + "typst-timing 0.12.0", "usvg", ] @@ -4006,7 +4006,25 @@ dependencies = [ "once_cell", "serde", "toml", - "typst-utils", + "typst-utils 0.12.0", + "unicode-ident", + "unicode-math-class", + "unicode-script", + "unicode-segmentation", + "unscanny", +] + +[[package]] +name = "typst-syntax" +version = "0.13.0-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb399d907ab219419b3e878b90cd67f62afd88de64704c6154edabce26708392" +dependencies = [ + "ecow", + "serde", + "toml", + "typst-timing 0.13.0-rc1", + "typst-utils 0.13.0-rc1", "unicode-ident", "unicode-math-class", "unicode-script", @@ -4023,7 +4041,18 @@ dependencies = [ "parking_lot", "serde", "serde_json", - "typst-syntax", + "typst-syntax 0.12.0", +] + +[[package]] +name = "typst-timing" +version = "0.13.0-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f17c136f66e19d46a997cf9f8d4392909e758100ff4741e55cd16dcad93c929" +dependencies = [ + "parking_lot", + "serde", + "serde_json", ] [[package]] @@ -4039,6 +4068,20 @@ dependencies = [ "thin-vec", ] +[[package]] +name = "typst-utils" +version = "0.13.0-rc1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37a7c14b1f7aae8c0fd515a4b33c6d036cd91b3cf6f8a1c7dcef503456cbbe30" +dependencies = [ + "once_cell", + "portable-atomic", + "rayon", + "siphasher 1.0.1", + "thin-vec", + "unicode-math-class", +] + [[package]] name = "typstyle" version = "0.12.14" @@ -4052,7 +4095,7 @@ dependencies = [ "insta-cmd", "log", "tempfile", - "typst-syntax", + "typst-syntax 0.13.0-rc1", "typstyle-core", "vergen", "vergen-gitcl", @@ -4087,7 +4130,7 @@ dependencies = [ "pretty", "rustc-hash", "serde", - "typst-syntax", + "typst-syntax 0.13.0-rc1", "wasm-bindgen", ] @@ -4099,7 +4142,7 @@ dependencies = [ "insta", "libtest-mimic", "pretty_assertions", - "typst-syntax", + "typst-syntax 0.13.0-rc1", "typstyle-consistency", "typstyle-core", ] diff --git a/Cargo.toml b/Cargo.toml index 0bc7873..3b568cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ typstyle = { path = "crates/typstyle", version = "0.12.14" } typstyle-consistency = { path = "crates/typstyle-consistency" } # Used in core -typst-syntax = "0.12.0" +typst-syntax = "0.13.0-rc1" ecow = "0.2.3" itertools = "0.13.0" diff --git a/crates/typstyle-core/src/pretty/mod.rs b/crates/typstyle-core/src/pretty/mod.rs index 4d3605e..37cca05 100644 --- a/crates/typstyle-core/src/pretty/mod.rs +++ b/crates/typstyle-core/src/pretty/mod.rs @@ -161,6 +161,7 @@ impl<'a> PrettyPrinter<'a> { Expr::Continue(c) => self.convert_continue(c), Expr::Return(r) => self.convert_return(r), Expr::Contextual(c) => self.convert_contextual(c), + Expr::MathText(math_text) => self.convert_trivia(math_text), } .group() } diff --git a/tests/fixtures/articles/snap/book.typ-0.snap b/tests/fixtures/articles/snap/book.typ-0.snap index dfd103b..9d372ec 100644 --- a/tests/fixtures/articles/snap/book.typ-0.snap +++ b/tests/fixtures/articles/snap/book.typ-0.snap @@ -1,7 +1,6 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/articles/book.typ -snapshot_kind: text --- // DUMMY @@ -80,9 +79,9 @@ snapshot_kind: text none, section: "6.1.1.1", )[Draft chapter] - // - #chapter(none, section: "6.1.1.2")[chapter with - markers] - // - #chapter(none, "= Introduction", section: "6.1.1.2") - // - #chapter(none, section: "6.1.1.2")[#text("= Introduction")] + // - #chapter(none, section: "6.1.1.2")[chapter with - markers] + // - #chapter(none, "= Introduction", section: "6.1.1.2") + // - #chapter(none, section: "6.1.1.2")[#text("= Introduction")] - #chapter( "format/build-meta.typ", section: "6.1.2", diff --git a/tests/fixtures/articles/snap/book.typ-120.snap b/tests/fixtures/articles/snap/book.typ-120.snap index 1522de4..e8ed513 100644 --- a/tests/fixtures/articles/snap/book.typ-120.snap +++ b/tests/fixtures/articles/snap/book.typ-120.snap @@ -1,7 +1,6 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/articles/book.typ -snapshot_kind: text --- // DUMMY @@ -35,9 +34,9 @@ snapshot_kind: text - #chapter("format/book.typ", section: "6.1")[book.typ] - #chapter("format/book-meta.typ", section: "6.1.1")[Book Metadata] - #chapter(none, section: "6.1.1.1")[Draft chapter] - // - #chapter(none, section: "6.1.1.2")[chapter with - markers] - // - #chapter(none, "= Introduction", section: "6.1.1.2") - // - #chapter(none, section: "6.1.1.2")[#text("= Introduction")] + // - #chapter(none, section: "6.1.1.2")[chapter with - markers] + // - #chapter(none, "= Introduction", section: "6.1.1.2") + // - #chapter(none, section: "6.1.1.2")[#text("= Introduction")] - #chapter("format/build-meta.typ", section: "6.1.2")[Build Metadata] - #chapter("format/theme.typ", section: "6.2")[Theme] - #chapter(none, section: "6.3")[Typst Support] diff --git a/tests/fixtures/articles/snap/book.typ-40.snap b/tests/fixtures/articles/snap/book.typ-40.snap index ba3b51c..3c9bdec 100644 --- a/tests/fixtures/articles/snap/book.typ-40.snap +++ b/tests/fixtures/articles/snap/book.typ-40.snap @@ -1,7 +1,6 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/articles/book.typ -snapshot_kind: text --- // DUMMY @@ -77,9 +76,9 @@ snapshot_kind: text none, section: "6.1.1.1", )[Draft chapter] - // - #chapter(none, section: "6.1.1.2")[chapter with - markers] - // - #chapter(none, "= Introduction", section: "6.1.1.2") - // - #chapter(none, section: "6.1.1.2")[#text("= Introduction")] + // - #chapter(none, section: "6.1.1.2")[chapter with - markers] + // - #chapter(none, "= Introduction", section: "6.1.1.2") + // - #chapter(none, section: "6.1.1.2")[#text("= Introduction")] - #chapter( "format/build-meta.typ", section: "6.1.2", diff --git a/tests/fixtures/articles/snap/book.typ-80.snap b/tests/fixtures/articles/snap/book.typ-80.snap index 1522de4..e8ed513 100644 --- a/tests/fixtures/articles/snap/book.typ-80.snap +++ b/tests/fixtures/articles/snap/book.typ-80.snap @@ -1,7 +1,6 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/articles/book.typ -snapshot_kind: text --- // DUMMY @@ -35,9 +34,9 @@ snapshot_kind: text - #chapter("format/book.typ", section: "6.1")[book.typ] - #chapter("format/book-meta.typ", section: "6.1.1")[Book Metadata] - #chapter(none, section: "6.1.1.1")[Draft chapter] - // - #chapter(none, section: "6.1.1.2")[chapter with - markers] - // - #chapter(none, "= Introduction", section: "6.1.1.2") - // - #chapter(none, section: "6.1.1.2")[#text("= Introduction")] + // - #chapter(none, section: "6.1.1.2")[chapter with - markers] + // - #chapter(none, "= Introduction", section: "6.1.1.2") + // - #chapter(none, section: "6.1.1.2")[#text("= Introduction")] - #chapter("format/build-meta.typ", section: "6.1.2")[Build Metadata] - #chapter("format/theme.typ", section: "6.2")[Theme] - #chapter(none, section: "6.3")[Typst Support] diff --git a/tests/fixtures/unit/comment/snap/convergence.typ-0.snap b/tests/fixtures/unit/comment/snap/convergence.typ-0.snap index 566fe68..ed72b2f 100644 --- a/tests/fixtures/unit/comment/snap/convergence.typ-0.snap +++ b/tests/fixtures/unit/comment/snap/convergence.typ-0.snap @@ -1,7 +1,6 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/unit/comment/convergence.typ -snapshot_kind: text --- #[ /* bar @@ -11,11 +10,11 @@ snapshot_kind: text - /* bar */ 123 -- /* bar - */ +- /* bar + */ -- /* foo - */ +- /* foo + */ #[ /* Somebody write this up: diff --git a/tests/fixtures/unit/comment/snap/convergence.typ-120.snap b/tests/fixtures/unit/comment/snap/convergence.typ-120.snap index 566fe68..ed72b2f 100644 --- a/tests/fixtures/unit/comment/snap/convergence.typ-120.snap +++ b/tests/fixtures/unit/comment/snap/convergence.typ-120.snap @@ -1,7 +1,6 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/unit/comment/convergence.typ -snapshot_kind: text --- #[ /* bar @@ -11,11 +10,11 @@ snapshot_kind: text - /* bar */ 123 -- /* bar - */ +- /* bar + */ -- /* foo - */ +- /* foo + */ #[ /* Somebody write this up: diff --git a/tests/fixtures/unit/comment/snap/convergence.typ-40.snap b/tests/fixtures/unit/comment/snap/convergence.typ-40.snap index 566fe68..ed72b2f 100644 --- a/tests/fixtures/unit/comment/snap/convergence.typ-40.snap +++ b/tests/fixtures/unit/comment/snap/convergence.typ-40.snap @@ -1,7 +1,6 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/unit/comment/convergence.typ -snapshot_kind: text --- #[ /* bar @@ -11,11 +10,11 @@ snapshot_kind: text - /* bar */ 123 -- /* bar - */ +- /* bar + */ -- /* foo - */ +- /* foo + */ #[ /* Somebody write this up: diff --git a/tests/fixtures/unit/comment/snap/convergence.typ-80.snap b/tests/fixtures/unit/comment/snap/convergence.typ-80.snap index 566fe68..ed72b2f 100644 --- a/tests/fixtures/unit/comment/snap/convergence.typ-80.snap +++ b/tests/fixtures/unit/comment/snap/convergence.typ-80.snap @@ -1,7 +1,6 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/unit/comment/convergence.typ -snapshot_kind: text --- #[ /* bar @@ -11,11 +10,11 @@ snapshot_kind: text - /* bar */ 123 -- /* bar - */ +- /* bar + */ -- /* foo - */ +- /* foo + */ #[ /* Somebody write this up: diff --git a/tests/fixtures/unit/markup/snap/raw-backtick.typ-0.snap b/tests/fixtures/unit/markup/snap/raw-backtick.typ-0.snap index 9bda056..31d1823 100644 --- a/tests/fixtures/unit/markup/snap/raw-backtick.typ-0.snap +++ b/tests/fixtures/unit/markup/snap/raw-backtick.typ-0.snap @@ -1,17 +1,16 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/unit/markup/raw-backtick.typ -snapshot_kind: text --- #( ``` ` ```, ) #( - ```js ` ``` + ```js` ``` ) #( - ```js `code` ``` + ```js`code` ``` ) #( - ```md `code`+other`code` ``` + ```md`code`+other`code` ``` ) diff --git a/tests/fixtures/unit/markup/snap/raw-backtick.typ-120.snap b/tests/fixtures/unit/markup/snap/raw-backtick.typ-120.snap index 7f396fa..0151442 100644 --- a/tests/fixtures/unit/markup/snap/raw-backtick.typ-120.snap +++ b/tests/fixtures/unit/markup/snap/raw-backtick.typ-120.snap @@ -1,9 +1,8 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/unit/markup/raw-backtick.typ -snapshot_kind: text --- #(``` ` ```,) -#(```js ` ```) -#(```js `code` ```) -#(```md `code`+other`code` ```) +#(```js` ```) +#(```js`code` ```) +#(```md`code`+other`code` ```) diff --git a/tests/fixtures/unit/markup/snap/raw-backtick.typ-40.snap b/tests/fixtures/unit/markup/snap/raw-backtick.typ-40.snap index 7f396fa..0151442 100644 --- a/tests/fixtures/unit/markup/snap/raw-backtick.typ-40.snap +++ b/tests/fixtures/unit/markup/snap/raw-backtick.typ-40.snap @@ -1,9 +1,8 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/unit/markup/raw-backtick.typ -snapshot_kind: text --- #(``` ` ```,) -#(```js ` ```) -#(```js `code` ```) -#(```md `code`+other`code` ```) +#(```js` ```) +#(```js`code` ```) +#(```md`code`+other`code` ```) diff --git a/tests/fixtures/unit/markup/snap/raw-backtick.typ-80.snap b/tests/fixtures/unit/markup/snap/raw-backtick.typ-80.snap index 7f396fa..0151442 100644 --- a/tests/fixtures/unit/markup/snap/raw-backtick.typ-80.snap +++ b/tests/fixtures/unit/markup/snap/raw-backtick.typ-80.snap @@ -1,9 +1,8 @@ --- source: tests/src/unit.rs input_file: tests/fixtures/unit/markup/raw-backtick.typ -snapshot_kind: text --- #(``` ` ```,) -#(```js ` ```) -#(```js `code` ```) -#(```md `code`+other`code` ```) +#(```js` ```) +#(```js`code` ```) +#(```md`code`+other`code` ```)