Skip to content

Commit

Permalink
Remove some locations and other warning stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
sitandr committed Oct 4, 2024
1 parent 1a5daf2 commit 469f980
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 51 deletions.
1 change: 0 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/basics/math/symbols.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
$
```

Expand Down
2 changes: 1 addition & 1 deletion src/basics/math/vec.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
$
```
Expand Down
20 changes: 0 additions & 20 deletions src/packages/tables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
```````
6 changes: 3 additions & 3 deletions src/snippets/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ In #ref-heading(<design>), 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 <test2>
Expand Down
7 changes: 3 additions & 4 deletions src/snippets/layout/multiline_detect.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -25,8 +25,7 @@ If the caption is multiline, it makes it left-aligned.
}
#align(my-align, it)
]))
])
}
#figure(caption: lorem(6))[
Expand Down
12 changes: 4 additions & 8 deletions src/snippets/math/vecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,23 +47,21 @@ 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,
..for row in rows.pos() {
(for el in row {
({
box(
width: measure(el, styles).width,
width: measure(el).width,
height: row-gap, place(horizon, el)
)
},)
}, )
}
)
)
}
$
Expand Down
16 changes: 8 additions & 8 deletions src/typstonomicon/block_break.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand All @@ -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({
Expand Down
6 changes: 5 additions & 1 deletion src/typstonomicon/totally-empty.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## Empty pages before chapters starting at odd pages

`````typ
<div class="warning">
This snippet has been broken on 0.12.0. If someone will help fixing it, this would be cool.
</div>

`````typ -norender
// author: janekfleper
#set page(height: 20em)
Expand Down
8 changes: 4 additions & 4 deletions src/typstonomicon/try_catch.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
// 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)[
#set align(center + horizon)
Could not find #raw(path)
]
}
})
}
#maybe-image("../tiger.jpg")
#maybe-image("../tiger1.jpg")
Expand Down

0 comments on commit 469f980

Please sign in to comment.