feat!: remove unfinished manual tagging code for now

This commit is contained in:
Tobias Schmitz 2025-07-13 17:31:48 +02:00
parent 484f633e27
commit b5c6f7132b
No known key found for this signature in database
4 changed files with 4 additions and 183 deletions

View File

@ -23,9 +23,7 @@ use typst_library::model::{
LinkElem, LinkTarget, ListElem, Outlinable, OutlineElem, OutlineEntry, ParElem, LinkElem, LinkTarget, ListElem, Outlinable, OutlineElem, OutlineEntry, ParElem,
ParbreakElem, QuoteElem, RefElem, StrongElem, TableCell, TableElem, TermsElem, Works, ParbreakElem, QuoteElem, RefElem, StrongElem, TableCell, TableElem, TermsElem, Works,
}; };
use typst_library::pdf::{ use typst_library::pdf::{ArtifactElem, EmbedElem, PdfMarkerTag, PdfMarkerTagKind};
ArtifactElem, EmbedElem, PdfMarkerTag, PdfMarkerTagKind, PdfTagElem,
};
use typst_library::text::{ use typst_library::text::{
DecoLine, Decoration, HighlightElem, ItalicToggle, LinebreakElem, LocalName, DecoLine, Decoration, HighlightElem, ItalicToggle, LinebreakElem, LocalName,
OverlineElem, RawElem, RawLine, ScriptKind, ShiftSettings, Smallcaps, SmallcapsElem, OverlineElem, RawElem, RawLine, ScriptKind, ShiftSettings, Smallcaps, SmallcapsElem,
@ -106,7 +104,6 @@ pub fn register(rules: &mut NativeRuleMap) {
// PDF. // PDF.
rules.register(Paged, EMBED_RULE); rules.register(Paged, EMBED_RULE);
rules.register(Paged, PDF_TAG_RULE);
rules.register(Paged, PDF_ARTIFACT_RULE); rules.register(Paged, PDF_ARTIFACT_RULE);
rules.register(Paged, PDF_MARKER_TAG_RULE); rules.register(Paged, PDF_MARKER_TAG_RULE);
} }
@ -930,8 +927,6 @@ const EQUATION_RULE: ShowFn<EquationElem> = |elem, _, styles| {
const EMBED_RULE: ShowFn<EmbedElem> = |_, _, _| Ok(Content::empty()); const EMBED_RULE: ShowFn<EmbedElem> = |_, _, _| Ok(Content::empty());
const PDF_TAG_RULE: ShowFn<PdfTagElem> = |elem, _, _| Ok(elem.body.clone());
const PDF_ARTIFACT_RULE: ShowFn<ArtifactElem> = |elem, _, _| Ok(elem.body.clone()); const PDF_ARTIFACT_RULE: ShowFn<ArtifactElem> = |elem, _, _| Ok(elem.body.clone());
const PDF_MARKER_TAG_RULE: ShowFn<PdfMarkerTag> = |elem, _, _| Ok(elem.body.clone()); const PDF_MARKER_TAG_RULE: ShowFn<PdfMarkerTag> = |elem, _, _| Ok(elem.body.clone());

View File

@ -1,177 +1,12 @@
use std::num::NonZeroU32; use std::num::NonZeroU32;
use ecow::EcoString; use typst_macros::{elem, func, Cast};
use typst_macros::{cast, elem, func, Cast};
use typst_utils::NonZeroExt; use typst_utils::NonZeroExt;
use crate::foundations::{Content, NativeElement, Smart}; use crate::foundations::{Content, NativeElement, Smart};
use crate::introspection::Locatable; use crate::introspection::Locatable;
use crate::model::TableCell; use crate::model::TableCell;
// TODO: docs
#[elem(Locatable)]
pub struct PdfTagElem {
#[default(PdfTagKind::NonStruct)]
pub kind: PdfTagKind,
/// An alternate description.
pub alt: Option<EcoString>,
/// Exact replacement for this structure element and its children.
pub actual_text: Option<EcoString>,
/// The expanded form of an abbreviation/acronym.
pub expansion: Option<EcoString>,
/// 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<EcoString> },
/// (Heading level 1)
H1 { title: Option<EcoString> },
/// (Heading level 2)
H2 { title: Option<EcoString> },
/// (Heading level 3)
H4 { title: Option<EcoString> },
/// (Heading level 4)
H3 { title: Option<EcoString> },
/// (Heading level 5)
H5 { title: Option<EcoString> },
/// (Heading level 6)
H6 { title: Option<EcoString> },
/// (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. /// Mark content as a PDF artifact.
/// TODO: maybe generalize this and use it to mark html elements with `aria-hidden="true"`? /// TODO: maybe generalize this and use it to mark html elements with `aria-hidden="true"`?
#[elem(Locatable)] #[elem(Locatable)]

View File

@ -13,7 +13,6 @@ pub fn module() -> Module {
let mut pdf = Scope::deduplicating(); let mut pdf = Scope::deduplicating();
pdf.start_category(crate::Category::Pdf); pdf.start_category(crate::Category::Pdf);
pdf.define_elem::<EmbedElem>(); pdf.define_elem::<EmbedElem>();
pdf.define_elem::<PdfTagElem>();
pdf.define_elem::<ArtifactElem>(); pdf.define_elem::<ArtifactElem>();
pdf.define_func::<header_cell>(); pdf.define_func::<header_cell>();
pdf.define_func::<data_cell>(); pdf.define_func::<data_cell>();

View File

@ -20,9 +20,7 @@ use typst_library::model::{
Destination, EnumElem, FigureCaption, FigureElem, HeadingElem, ListElem, Outlinable, Destination, EnumElem, FigureCaption, FigureElem, HeadingElem, ListElem, Outlinable,
OutlineEntry, TableCell, TableElem, OutlineEntry, TableCell, TableElem,
}; };
use typst_library::pdf::{ use typst_library::pdf::{ArtifactElem, ArtifactKind, PdfMarkerTag, PdfMarkerTagKind};
ArtifactElem, ArtifactKind, PdfMarkerTag, PdfMarkerTagKind, PdfTagElem, PdfTagKind,
};
use typst_library::visualize::ImageElem; use typst_library::visualize::ImageElem;
use crate::convert::GlobalContext; use crate::convert::GlobalContext;
@ -56,13 +54,7 @@ pub(crate) fn handle_start(
return Ok(()); return Ok(());
} }
let tag: Tag = if let Some(pdf_tag) = elem.to_packed::<PdfTagElem>() { let tag: Tag = if let Some(tag) = elem.to_packed::<PdfMarkerTag>() {
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::<PdfMarkerTag>() {
match tag.kind { match tag.kind {
PdfMarkerTagKind::OutlineBody => { PdfMarkerTagKind::OutlineBody => {
push_stack(gc, loc, StackEntryKind::Outline(OutlineCtx::new()))?; push_stack(gc, loc, StackEntryKind::Outline(OutlineCtx::new()))?;