diff --git a/crates/typst-layout/src/rules.rs b/crates/typst-layout/src/rules.rs index 8d3e6da4f..ccdae8c68 100644 --- a/crates/typst-layout/src/rules.rs +++ b/crates/typst-layout/src/rules.rs @@ -23,9 +23,7 @@ use typst_library::model::{ LinkElem, LinkTarget, ListElem, Outlinable, OutlineElem, OutlineEntry, ParElem, ParbreakElem, QuoteElem, RefElem, StrongElem, TableCell, TableElem, TermsElem, Works, }; -use typst_library::pdf::{ - ArtifactElem, EmbedElem, PdfMarkerTag, PdfMarkerTagKind, PdfTagElem, -}; +use typst_library::pdf::{ArtifactElem, EmbedElem, PdfMarkerTag, PdfMarkerTagKind}; use typst_library::text::{ DecoLine, Decoration, HighlightElem, ItalicToggle, LinebreakElem, LocalName, OverlineElem, RawElem, RawLine, ScriptKind, ShiftSettings, Smallcaps, SmallcapsElem, @@ -106,7 +104,6 @@ pub fn register(rules: &mut NativeRuleMap) { // PDF. rules.register(Paged, EMBED_RULE); - rules.register(Paged, PDF_TAG_RULE); rules.register(Paged, PDF_ARTIFACT_RULE); rules.register(Paged, PDF_MARKER_TAG_RULE); } @@ -930,8 +927,6 @@ const EQUATION_RULE: ShowFn = |elem, _, styles| { const EMBED_RULE: ShowFn = |_, _, _| Ok(Content::empty()); -const PDF_TAG_RULE: ShowFn = |elem, _, _| Ok(elem.body.clone()); - const PDF_ARTIFACT_RULE: ShowFn = |elem, _, _| Ok(elem.body.clone()); const PDF_MARKER_TAG_RULE: ShowFn = |elem, _, _| Ok(elem.body.clone()); diff --git a/crates/typst-library/src/pdf/accessibility.rs b/crates/typst-library/src/pdf/accessibility.rs index e4213542b..f987a7645 100644 --- a/crates/typst-library/src/pdf/accessibility.rs +++ b/crates/typst-library/src/pdf/accessibility.rs @@ -1,177 +1,12 @@ use std::num::NonZeroU32; -use ecow::EcoString; -use typst_macros::{cast, elem, func, Cast}; +use typst_macros::{elem, func, Cast}; use typst_utils::NonZeroExt; use crate::foundations::{Content, NativeElement, Smart}; use crate::introspection::Locatable; use crate::model::TableCell; -// TODO: docs -#[elem(Locatable)] -pub struct PdfTagElem { - #[default(PdfTagKind::NonStruct)] - pub kind: PdfTagKind, - - /// An alternate description. - pub alt: Option, - /// Exact replacement for this structure element and its children. - pub actual_text: Option, - /// The expanded form of an abbreviation/acronym. - pub expansion: Option, - - /// The content to underline. - #[required] - pub body: Content, -} - -// TODO: docs -/// PDF structure elements -#[derive(Clone, Debug, PartialEq, Eq, Hash)] -pub enum PdfTagKind { - // grouping elements - /// (Part) - Part, - /// (Article) - Art, - /// (Section) - Sect, - /// (Division) - Div, - /// (Block quotation) - BlockQuote, - /// (Caption) - Caption, - /// (Table of contents) - TOC, - /// (Table of contents item) - TOCI, - /// (Index) - Index, - /// (Nonstructural element) - NonStruct, - /// (Private element) - Private, - - // paragraph like elements - /// (Heading) - H { title: Option }, - /// (Heading level 1) - H1 { title: Option }, - /// (Heading level 2) - H2 { title: Option }, - /// (Heading level 3) - H4 { title: Option }, - /// (Heading level 4) - H3 { title: Option }, - /// (Heading level 5) - H5 { title: Option }, - /// (Heading level 6) - H6 { title: Option }, - /// (Paragraph) - P, - - // list elements - /// (List) - L { numbering: ListNumbering }, - /// (List item) - LI, - /// (Label) - Lbl, - /// (List body) - LBody, - - // table elements - /// (Table) - Table, - /// (Table row) - TR, - /// (Table header) - TH { scope: TableHeaderScope }, - /// (Table data cell) - TD, - /// (Table header row group) - THead, - /// (Table body row group) - TBody, - /// (Table footer row group) - TFoot, - - // inline elements - /// (Span) - Span, - /// (Quotation) - Quote, - /// (Note) - Note, - /// (Reference) - Reference, - /// (Bibliography Entry) - BibEntry, - /// (Code) - Code, - /// (Link) - Link, - /// (Annotation) - Annot, - - /// (Ruby) - Ruby, - /// (Ruby base text) - RB, - /// (Ruby annotation text) - RT, - /// (Ruby punctuation) - RP, - - /// (Warichu) - Warichu, - /// (Warichu text) - WT, - /// (Warichu punctuation) - WP, - - /// (Figure) - Figure, - /// (Formula) - Formula, - /// (Form) - Form, -} - -cast! { - PdfTagKind, - self => match self { - PdfTagKind::Part => "part".into_value(), - _ => todo!(), - }, - "part" => Self::Part, - // TODO -} - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub enum ListNumbering { - /// No numbering. - None, - /// Solid circular bullets. - Disc, - /// Open circular bullets. - Circle, - /// Solid square bullets. - Square, - /// Decimal numbers. - Decimal, - /// Lowercase Roman numerals. - LowerRoman, - /// Uppercase Roman numerals. - UpperRoman, - /// Lowercase letters. - LowerAlpha, - /// Uppercase letters. - UpperAlpha, -} - /// Mark content as a PDF artifact. /// TODO: maybe generalize this and use it to mark html elements with `aria-hidden="true"`? #[elem(Locatable)] diff --git a/crates/typst-library/src/pdf/mod.rs b/crates/typst-library/src/pdf/mod.rs index 8a0d40b9c..869b20496 100644 --- a/crates/typst-library/src/pdf/mod.rs +++ b/crates/typst-library/src/pdf/mod.rs @@ -13,7 +13,6 @@ pub fn module() -> Module { let mut pdf = Scope::deduplicating(); pdf.start_category(crate::Category::Pdf); pdf.define_elem::(); - pdf.define_elem::(); pdf.define_elem::(); pdf.define_func::(); pdf.define_func::(); diff --git a/crates/typst-pdf/src/tags/mod.rs b/crates/typst-pdf/src/tags/mod.rs index d7fe24f78..e65f73aa0 100644 --- a/crates/typst-pdf/src/tags/mod.rs +++ b/crates/typst-pdf/src/tags/mod.rs @@ -20,9 +20,7 @@ use typst_library::model::{ Destination, EnumElem, FigureCaption, FigureElem, HeadingElem, ListElem, Outlinable, OutlineEntry, TableCell, TableElem, }; -use typst_library::pdf::{ - ArtifactElem, ArtifactKind, PdfMarkerTag, PdfMarkerTagKind, PdfTagElem, PdfTagKind, -}; +use typst_library::pdf::{ArtifactElem, ArtifactKind, PdfMarkerTag, PdfMarkerTagKind}; use typst_library::visualize::ImageElem; use crate::convert::GlobalContext; @@ -56,13 +54,7 @@ pub(crate) fn handle_start( return Ok(()); } - let tag: Tag = if let Some(pdf_tag) = elem.to_packed::() { - let kind = pdf_tag.kind.get_ref(StyleChain::default()); - match kind { - PdfTagKind::Part => TagKind::Part.into(), - _ => todo!(), - } - } else if let Some(tag) = elem.to_packed::() { + let tag: Tag = if let Some(tag) = elem.to_packed::() { match tag.kind { PdfMarkerTagKind::OutlineBody => { push_stack(gc, loc, StackEntryKind::Outline(OutlineCtx::new()))?;