mirror of
https://github.com/typst/typst
synced 2025-07-27 14:27:56 +08:00
refactor: update krilla
This commit is contained in:
parent
39a2c31169
commit
153c5d3a4a
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -1373,7 +1373,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "krilla"
|
name = "krilla"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
source = "git+https://github.com/saecki/krilla?branch=tag-attributes#5ae27ecab2f74d7a5e58b962f04c85bc2662602e"
|
source = "git+https://github.com/LaurenzV/krilla?branch=main#c0a456829bb63212470a6fa29d604dd9e051a9bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
@ -1402,7 +1402,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "krilla-svg"
|
name = "krilla-svg"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/saecki/krilla?branch=tag-attributes#5ae27ecab2f74d7a5e58b962f04c85bc2662602e"
|
source = "git+https://github.com/LaurenzV/krilla?branch=main#c0a456829bb63212470a6fa29d604dd9e051a9bd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flate2",
|
"flate2",
|
||||||
"fontdb",
|
"fontdb",
|
||||||
|
@ -73,8 +73,8 @@ image = { version = "0.25.5", default-features = false, features = ["png", "jpeg
|
|||||||
indexmap = { version = "2", features = ["serde"] }
|
indexmap = { version = "2", features = ["serde"] }
|
||||||
infer = { version = "0.19.0", default-features = false }
|
infer = { version = "0.19.0", default-features = false }
|
||||||
kamadak-exif = "0.6"
|
kamadak-exif = "0.6"
|
||||||
krilla = { git = "https://github.com/saecki/krilla", branch = "tag-attributes", default-features = false, features = ["raster-images", "comemo", "rayon"] }
|
krilla = { git = "https://github.com/LaurenzV/krilla", branch = "main", default-features = false, features = ["raster-images", "comemo", "rayon"] }
|
||||||
krilla-svg = { git = "https://github.com/saecki/krilla", branch = "tag-attributes" }
|
krilla-svg = { git = "https://github.com/LaurenzV/krilla", branch = "main" }
|
||||||
kurbo = "0.11"
|
kurbo = "0.11"
|
||||||
libfuzzer-sys = "0.4"
|
libfuzzer-sys = "0.4"
|
||||||
lipsum = "0.9"
|
lipsum = "0.9"
|
||||||
|
@ -3,7 +3,7 @@ use std::num::NonZeroU32;
|
|||||||
|
|
||||||
use az::SaturatingAs;
|
use az::SaturatingAs;
|
||||||
use krilla::tagging::{
|
use krilla::tagging::{
|
||||||
TableCellSpan, TableDataCell, TableHeaderCell, TagBuilder, TagId, TagIdRefs, TagKind,
|
TableCellSpan, TableDataCell, TableHeaderCell, TagBuilder, TagId, TagKind,
|
||||||
};
|
};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use typst_library::foundations::{Packed, Smart, StyleChain};
|
use typst_library::foundations::{Packed, Smart, StyleChain};
|
||||||
@ -90,7 +90,7 @@ impl TableCtx {
|
|||||||
rowspan: rowspan.try_into().unwrap_or(NonZeroU32::MAX),
|
rowspan: rowspan.try_into().unwrap_or(NonZeroU32::MAX),
|
||||||
colspan: colspan.try_into().unwrap_or(NonZeroU32::MAX),
|
colspan: colspan.try_into().unwrap_or(NonZeroU32::MAX),
|
||||||
kind,
|
kind,
|
||||||
headers: TagIdRefs::NONE,
|
headers: SmallVec::new(),
|
||||||
nodes,
|
nodes,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -244,8 +244,8 @@ impl TableCtx {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some((_, cell_id)) = current_header.last() {
|
if let Some((_, cell_id)) = current_header.last() {
|
||||||
if !cell.headers.ids.contains(&cell_id) {
|
if !cell.headers.contains(&cell_id) {
|
||||||
cell.headers.ids.push(cell_id.clone());
|
cell.headers.push(cell_id.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,7 +294,7 @@ struct TableCtxCell {
|
|||||||
rowspan: NonZeroU32,
|
rowspan: NonZeroU32,
|
||||||
colspan: NonZeroU32,
|
colspan: NonZeroU32,
|
||||||
kind: Smart<TableCellKind>,
|
kind: Smart<TableCellKind>,
|
||||||
headers: TagIdRefs,
|
headers: SmallVec<[TagId; 1]>,
|
||||||
nodes: Vec<TagNode>,
|
nodes: Vec<TagNode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,9 +314,9 @@ fn should_group_rows(a: TableCellKind, b: TableCellKind) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn table_cell_id(table_id: TableId, x: u32, y: u32) -> TagId {
|
fn table_cell_id(table_id: TableId, x: u32, y: u32) -> TagId {
|
||||||
let mut buf = SmallVec::new();
|
let mut buf = SmallVec::<[u8; 32]>::new();
|
||||||
_ = write!(&mut buf, "{}x{x}y{y}", table_id.0);
|
_ = write!(&mut buf, "{}x{x}y{y}", table_id.0);
|
||||||
TagId::from_smallvec(buf)
|
TagId::from(buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn table_header_scope(scope: TableHeaderScope) -> krilla::tagging::TableHeaderScope {
|
fn table_header_scope(scope: TableHeaderScope) -> krilla::tagging::TableHeaderScope {
|
||||||
@ -414,24 +414,17 @@ mod tests {
|
|||||||
) -> TagNode {
|
) -> TagNode {
|
||||||
let scope = table_header_scope(scope);
|
let scope = table_header_scope(scope);
|
||||||
let id = table_cell_id(TableId(324), x, y);
|
let id = table_cell_id(TableId(324), x, y);
|
||||||
let ids = headers
|
let ids = headers.map(|(x, y)| table_cell_id(TableId(324), x, y));
|
||||||
.map(|(x, y)| table_cell_id(TableId(324), x, y))
|
|
||||||
.into_iter()
|
|
||||||
.collect();
|
|
||||||
TagNode::Group(
|
TagNode::Group(
|
||||||
TagKind::TH(TableHeaderCell::new(scope).with_headers(TagIdRefs { ids }))
|
TagKind::TH(TableHeaderCell::new(scope).with_headers(ids)).with_id(Some(id)),
|
||||||
.with_id(Some(id)),
|
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn td<const SIZE: usize>(headers: [(u32, u32); SIZE]) -> TagNode {
|
fn td<const SIZE: usize>(headers: [(u32, u32); SIZE]) -> TagNode {
|
||||||
let ids = headers
|
let ids = headers.map(|(x, y)| table_cell_id(TableId(324), x, y));
|
||||||
.map(|(x, y)| table_cell_id(TableId(324), x, y))
|
|
||||||
.into_iter()
|
|
||||||
.collect();
|
|
||||||
TagNode::Group(
|
TagNode::Group(
|
||||||
TagKind::TD(TableDataCell::new().with_headers(TagIdRefs { ids })).into(),
|
TagKind::TD(TableDataCell::new().with_headers(ids)).into(),
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user