From 469f980914900673ccaa92840e7a1b5ef9026b6e Mon Sep 17 00:00:00 2001 From: sitandr Date: Fri, 4 Oct 2024 16:14:34 +0300 Subject: [PATCH] Remove some locations and other warning stuff --- src/SUMMARY.md | 1 - src/basics/math/symbols.md | 2 +- src/basics/math/vec.md | 2 +- src/packages/tables.md | 20 -------------------- src/snippets/labels.md | 6 +++--- src/snippets/layout/multiline_detect.md | 7 +++---- src/snippets/math/vecs.md | 12 ++++-------- src/typstonomicon/block_break.md | 16 ++++++++-------- src/typstonomicon/totally-empty.md | 6 +++++- src/typstonomicon/try_catch.md | 8 ++++---- 10 files changed, 29 insertions(+), 51 deletions(-) diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 205ec94..6b39ad5 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -26,7 +26,6 @@ - [Tips](./basics/scripting/tips.md) - [States, Query, Context Dependence](./basics/states/index.md) - [States](./basics/states/states.md) - - [Locate](./basics/states/locate.md) - [Counters](./basics/states/counters.md) - [Measure, Layout](./basics/measure.md) - [Query](./basics/states/query.md) diff --git a/src/basics/math/symbols.md b/src/basics/math/symbols.md index 6482a1d..5cea796 100644 --- a/src/basics/math/symbols.md +++ b/src/basics/math/symbols.md @@ -32,7 +32,7 @@ $ integral, integral.cont, integral.double, integral.square, sum.integral\ // lt — less than, gt — greater than -lt, lt.circle, lt.curly, lt.eq, lt.eq.curly, lt.not, lt.eq.not, lt.eq.not.curly, gt, lt.gt.eq, lt.gt.not +lt, lt.circle, lt.eq, lt.not, lt.eq.not, lt.tri, lt.tri.eq, lt.tri.eq.not, gt, lt.gt.eq, lt.gt.not $ ``` diff --git a/src/basics/math/vec.md b/src/basics/math/vec.md index 22227d1..3f0fca1 100644 --- a/src/basics/math/vec.md +++ b/src/basics/math/vec.md @@ -20,7 +20,7 @@ You can change parentheses around the column or even remove them: ```typ $ vec(1, 2, 3, delim: "{") \ -vec(1, 2, 3, delim: "||") \ +vec(1, 2, 3, delim: bar.double) \ vec(1, 2, 3, delim: #none) $ ``` diff --git a/src/packages/tables.md b/src/packages/tables.md index f32f3dc..d19d255 100644 --- a/src/packages/tables.md +++ b/src/packages/tables.md @@ -266,23 +266,3 @@ Render markdown tables in Typst. | Wally | Third Av. | 160 cm | 10 | ] ``` - -### Tbl: compact syntax - -Compact syntax and some new features: - -```````typ -#import "@preview/tbl:0.0.4" -#show: tbl.template.with(box: true, tab: "|") - -```tbl - R | L - R N. -software|version -_ - AFL|2.39b - Mutt|1.8.0 - Ruby|1.8.7.374 -TeX Live|2015 -``` -``````` \ No newline at end of file diff --git a/src/snippets/labels.md b/src/snippets/labels.md index dfe0d8b..3725e48 100644 --- a/src/snippets/labels.md +++ b/src/snippets/labels.md @@ -26,14 +26,14 @@ In #ref-heading(), we discussed... // author: Enivex #set heading(numbering: "1.") -#let myref(label) = locate(loc =>{ - if query(label,loc).len() != 0 { +#let myref(label) = context { + if query(label).len() != 0 { ref(label) } else { // missing reference text(fill: red)[???] } -}) +} = Second diff --git a/src/snippets/layout/multiline_detect.md b/src/snippets/layout/multiline_detect.md index 00f10e4..9c63c34 100644 --- a/src/snippets/layout/multiline_detect.md +++ b/src/snippets/layout/multiline_detect.md @@ -10,10 +10,10 @@ If the caption is multiline, it makes it left-aligned. `````typ #show figure.caption: it => { - layout(size => style(styles => [ + layout(size => context [ #let text-size = measure( + ..size, it.supplement + it.separator + it.body, - styles, ) #let my-align @@ -25,8 +25,7 @@ If the caption is multiline, it makes it left-aligned. } #align(my-align, it) - - ])) + ]) } #figure(caption: lorem(6))[ diff --git a/src/snippets/math/vecs.md b/src/snippets/math/vecs.md index 6c81273..e667700 100644 --- a/src/snippets/math/vecs.md +++ b/src/snippets/math/vecs.md @@ -14,21 +14,19 @@ To fix this, you can use this snippet: ```typ // Fixed height vector #let fvec(..children, delim: "(", gap: 1.5em) = { // change default gap there - style(styles => - math.vec( + context math.vec( delim: delim, gap: 0em, ..for el in children.pos() { ({ box( - width: measure(el, styles).width, + width: measure(el).width, height: gap, place(horizon, el) ) },) // this is an array // `for` merges all these arrays, then we pass it to arguments } ) - ) } // fixed hight matrix @@ -49,8 +47,7 @@ To fix this, you can use this snippet: column-gap = rows.named().at("column-gap", default: 0.5em) } - style(styles => - math.mat( + context math.mat( delim: delim, row-gap: 0em, column-gap: column-gap, @@ -58,14 +55,13 @@ To fix this, you can use this snippet: (for el in row { ({ box( - width: measure(el, styles).width, + width: measure(el).width, height: row-gap, place(horizon, el) ) },) }, ) } ) - ) } $ diff --git a/src/typstonomicon/block_break.md b/src/typstonomicon/block_break.md index bf420ab..9256206 100644 --- a/src/typstonomicon/block_break.md +++ b/src/typstonomicon/block_break.md @@ -172,8 +172,8 @@ See a demo project (more comments, I stripped some of them) [there](https://typs endSelector = endSelector.before(loc) } - let startMarkers = query(startSelector, loc) - let endMarkers = query(endSelector, loc) + let startMarkers = query(startSelector) + let endMarkers = query(endSelector) let currentPage = loc.position().page let pageStartMarkers = startMarkers.filter(elem => @@ -188,22 +188,22 @@ See a demo project (more comments, I stripped some of them) [there](https://typs #set page( margin: 2em, // ... other page setup here ... - header: locate(loc => { - let boundaryCount = countBoundaries(loc, true) + header: context { + let boundaryCount = countBoundaries(here(), true) if boundaryCount.end > boundaryCount.start { // Decorate this header with an opening decoration [Block break top: $-->$] } - }), - footer: locate(loc => { - let boundaryCount = countBoundaries(loc, false) + }, + footer: context { + let boundaryCount = countBoundaries(here(), false) if boundaryCount.start > boundaryCount.end { // Decorate this footer with a closing decoration [Block break end: $<--$] } - }) + } ) #let breakable-block(body) = block({ diff --git a/src/typstonomicon/totally-empty.md b/src/typstonomicon/totally-empty.md index 5b905fd..d127de9 100644 --- a/src/typstonomicon/totally-empty.md +++ b/src/typstonomicon/totally-empty.md @@ -2,7 +2,11 @@ ## Empty pages before chapters starting at odd pages -`````typ +
+ This snippet has been broken on 0.12.0. If someone will help fixing it, this would be cool. +
+ +`````typ -norender // author: janekfleper #set page(height: 20em) diff --git a/src/typstonomicon/try_catch.md b/src/typstonomicon/try_catch.md index e0ec040..044e5bf 100644 --- a/src/typstonomicon/try_catch.md +++ b/src/typstonomicon/try_catch.md @@ -3,10 +3,10 @@ // author: laurmaedje // Renders an image or a placeholder if it doesn't exist. // Don’t try this at home, kids! -#let maybe-image(path, ..args) = locate(loc => { +#let maybe-image(path, ..args) = context { let path-label = label(path) - let first-time = query(locate(_ => {}).func(), loc).len() == 0 - if first-time or query(path-label, loc).len() > 0 { + let first-time = query((context {}).func()).len() == 0 + if first-time or query(path-label).len() > 0 { [#image(path, ..args)#path-label] } else { rect(width: 50%, height: 5em, fill: luma(235), stroke: 1pt)[ @@ -14,7 +14,7 @@ Could not find #raw(path) ] } -}) +} #maybe-image("../tiger.jpg") #maybe-image("../tiger1.jpg")