diff options
| author | Tobias Schmitz <tobiasschmitz2001@gmail.com> | 2025-06-27 14:20:58 +0200 |
|---|---|---|
| committer | Tobias Schmitz <tobiasschmitz2001@gmail.com> | 2025-07-03 18:43:08 +0200 |
| commit | bfcf2bd4cced0b3f08b9b00af9bb14b824aabb13 (patch) | |
| tree | 96157c278642c8b4ffdc008b216a5bed81a9d851 | |
| parent | 605681d4356a66f0d05b0d0036419db374852f8c (diff) | |
feat: support headings with level >= 7
| -rw-r--r-- | crates/typst-pdf/src/tags.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/crates/typst-pdf/src/tags.rs b/crates/typst-pdf/src/tags.rs index 5b596394..8a7e1362 100644 --- a/crates/typst-pdf/src/tags.rs +++ b/crates/typst-pdf/src/tags.rs @@ -1,4 +1,5 @@ use std::cell::OnceCell; +use std::num::NonZeroU32; use ecow::EcoString; use krilla::page::Page; @@ -372,17 +373,9 @@ pub(crate) fn handle_start(gc: &mut GlobalContext, elem: &Content) { _ => todo!(), } } else if let Some(heading) = elem.to_packed::<HeadingElem>() { - let level = heading.level(); + let level = heading.level().try_into().unwrap_or(NonZeroU32::MAX); let name = heading.body.plain_text().to_string(); - match level.get() { - 1 => TagKind::H1(Some(name)).into(), - 2 => TagKind::H2(Some(name)).into(), - 3 => TagKind::H3(Some(name)).into(), - 4 => TagKind::H4(Some(name)).into(), - 5 => TagKind::H5(Some(name)).into(), - // TODO: when targeting PDF 2.0 headings `> 6` are supported - _ => TagKind::H6(Some(name)).into(), - } + TagKind::Hn(level, Some(name)).into() } else if let Some(_) = elem.to_packed::<OutlineBody>() { push_stack(gc, loc, StackEntryKind::Outline(OutlineCtx::new())); return; |
