fix: handle dstu-table refs and counting

This commit is contained in:
ilyaoc
2026-06-03 13:58:03 +02:00
parent 0162eb8c40
commit d70e9df912
3 changed files with 15 additions and 3 deletions
+13 -1
View File
@@ -49,6 +49,7 @@
caption: none, caption: none,
columns: none, columns: none,
header: none, header: none,
tag: none,
..args, ..args,
) = { ) = {
let caption = _required("caption", caption) let caption = _required("caption", caption)
@@ -63,7 +64,6 @@
let named = args.named() let named = args.named()
let body = args.pos() let body = args.pos()
context { context {
let h = counter(heading).get() let h = counter(heading).get()
let section = if h.len() > 0 { h.at(0) } else { 0 } let section = if h.len() > 0 { h.at(0) } else { 0 }
@@ -85,6 +85,8 @@
{ {
set block(spacing: dstu-table-caption-gap) set block(spacing: dstu-table-caption-gap)
[#metadata((kind: "dstu-table", number: num)) #if tag != none { label(tag) }]
block(sticky: true)[ block(sticky: true)[
#dstu-table-label[Таблиця #num -- #caption] #dstu-table-label[Таблиця #num -- #caption]
] ]
@@ -169,6 +171,16 @@
set list(indent: indent-size + 0.1cm, body-indent: 0.5cm, marker: [--]) set list(indent: indent-size + 0.1cm, body-indent: 0.5cm, marker: [--])
// Figures // Figures
show ref: it => {
let el = it.element
if el != none and el.func() == metadata and type(el.value) == dictionary and el.value.at("kind", default: none) == "dstu-table" {
link(el.location())[#el.value.at("number")]
} else {
it
}
}
show figure: it => { show figure: it => {
v(double-spacing, weak: true) v(double-spacing, weak: true)
it it
+1 -1
View File
@@ -314,7 +314,7 @@
#context [ #context [
#let pages = counter(page).final().at(0) #let pages = counter(page).final().at(0)
#let images = query(figure.where(kind: image)).len() #let images = query(figure.where(kind: image)).len()
#let dstu-tables = query(metadata).filter(it => type(it.value) == str and it.value.starts-with("start-dstu-table-")).len() #let dstu-tables = query(metadata).filter(it => type(it.value) == dictionary and it.value.at("kind", default: none) == "dstu-table").len()
#let tables = query(figure.where(kind: table)).len() + dstu-tables #let tables = query(figure.where(kind: table)).len() + dstu-tables
#let bibs = bib-count.final().dedup().len() #let bibs = bib-count.final().dedup().len()
+1 -1
View File
@@ -210,7 +210,7 @@
#context [ #context [
#let pages = counter(page).final().at(0) #let pages = counter(page).final().at(0)
#let images = query(figure.where(kind: image)).len() #let images = query(figure.where(kind: image)).len()
#let dstu-tables = query(metadata).filter(it => type(it.value) == str and it.value.starts-with("start-dstu-table-")).len() #let dstu-tables = query(metadata).filter(it => type(it.value) == dictionary and it.value.at("kind", default: none) == "dstu-table").len()
#let tables = query(figure.where(kind: table)).len() + dstu-tables #let tables = query(figure.where(kind: table)).len() + dstu-tables
#let bibs = bib-count.final().dedup().len() #let bibs = bib-count.final().dedup().len()
/* TODO: why this stopped working? /* TODO: why this stopped working?