mirror of
https://github.com/typst/typst
synced 2025-08-20 01:48:34 +08:00
WIP [no ci]
This commit is contained in:
parent
8a97c1ee57
commit
5ada3bb3cd
@ -185,6 +185,8 @@ fn layout_page_run_impl(
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Layouts a single marginal.
|
// Layouts a single marginal.
|
||||||
|
// TODO: add some sort of tag that indicates the marginals and use it to
|
||||||
|
// mark them as artifacts for PDF/UA.
|
||||||
let mut layout_marginal = |content: &Option<Content>, area, align| {
|
let mut layout_marginal = |content: &Option<Content>, area, align| {
|
||||||
let Some(content) = content else { return Ok(None) };
|
let Some(content) = content else { return Ok(None) };
|
||||||
let aligned = content.clone().styled(AlignElem::set_alignment(align));
|
let aligned = content.clone().styled(AlignElem::set_alignment(align));
|
||||||
|
@ -49,6 +49,8 @@ pub fn convert(
|
|||||||
xmp_metadata: true,
|
xmp_metadata: true,
|
||||||
cmyk_profile: None,
|
cmyk_profile: None,
|
||||||
configuration: config,
|
configuration: config,
|
||||||
|
// TODO: Should we just set this to false? If set to `false` this will
|
||||||
|
// automatically be enabled if the `UA1` validator is used.
|
||||||
enable_tagging: true,
|
enable_tagging: true,
|
||||||
render_svg_glyph_fn: render_svg_glyph,
|
render_svg_glyph_fn: render_svg_glyph,
|
||||||
};
|
};
|
||||||
@ -115,6 +117,8 @@ fn convert_pages(gc: &mut GlobalContext, document: &mut Document) -> SourceResul
|
|||||||
let mut surface = page.surface();
|
let mut surface = page.surface();
|
||||||
let mut fc = FrameContext::new(typst_page.frame.size());
|
let mut fc = FrameContext::new(typst_page.frame.size());
|
||||||
|
|
||||||
|
// TODO: PDF/UA tags may not cross page boundaries: close tags left
|
||||||
|
// in the stack and reopen them on a new page
|
||||||
handle_frame(
|
handle_frame(
|
||||||
&mut fc,
|
&mut fc,
|
||||||
&typst_page.frame,
|
&typst_page.frame,
|
||||||
@ -295,7 +299,10 @@ pub(crate) fn handle_frame(
|
|||||||
FrameItem::Link(d, s) => handle_link(fc, gc, d, *s),
|
FrameItem::Link(d, s) => handle_link(fc, gc, d, *s),
|
||||||
FrameItem::Tag(introspection::Tag::Start(elem)) => {
|
FrameItem::Tag(introspection::Tag::Start(elem)) => {
|
||||||
let Some(heading) = elem.to_packed::<HeadingElem>() else { continue };
|
let Some(heading) = elem.to_packed::<HeadingElem>() else { continue };
|
||||||
let Some(loc) = heading.location() else { continue };
|
let loc = heading.location().expect("heading element to have a location");
|
||||||
|
|
||||||
|
// TODO: PDF/UA "Logical Structure" should not include artifacts:
|
||||||
|
// mabye close all open tags before an artifact and reopen them after?
|
||||||
|
|
||||||
let level = heading.resolve_level(StyleChain::default());
|
let level = heading.resolve_level(StyleChain::default());
|
||||||
let name = heading.body.plain_text().to_string();
|
let name = heading.body.plain_text().to_string();
|
||||||
@ -311,6 +318,8 @@ pub(crate) fn handle_frame(
|
|||||||
};
|
};
|
||||||
let mut tag_group = TagGroup::new(tag);
|
let mut tag_group = TagGroup::new(tag);
|
||||||
tag_group.push(Node::Leaf(heading_id));
|
tag_group.push(Node::Leaf(heading_id));
|
||||||
|
// TODO: Keep track of the logical document hierarchy and build
|
||||||
|
// a proper tag tree.
|
||||||
gc.tags.push(Node::Group(tag_group));
|
gc.tags.push(Node::Group(tag_group));
|
||||||
|
|
||||||
gc.tag_stack.push(loc);
|
gc.tag_stack.push(loc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user