mirror of
https://github.com/typst/typst
synced 2025-07-27 14:27:56 +08:00
feat: support headings with level >= 7
This commit is contained in:
parent
605681d435
commit
bfcf2bd4cc
@ -1,4 +1,5 @@
|
|||||||
use std::cell::OnceCell;
|
use std::cell::OnceCell;
|
||||||
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
use ecow::EcoString;
|
use ecow::EcoString;
|
||||||
use krilla::page::Page;
|
use krilla::page::Page;
|
||||||
@ -372,17 +373,9 @@ pub(crate) fn handle_start(gc: &mut GlobalContext, elem: &Content) {
|
|||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
} else if let Some(heading) = elem.to_packed::<HeadingElem>() {
|
} 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();
|
let name = heading.body.plain_text().to_string();
|
||||||
match level.get() {
|
TagKind::Hn(level, Some(name)).into()
|
||||||
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(),
|
|
||||||
}
|
|
||||||
} else if let Some(_) = elem.to_packed::<OutlineBody>() {
|
} else if let Some(_) = elem.to_packed::<OutlineBody>() {
|
||||||
push_stack(gc, loc, StackEntryKind::Outline(OutlineCtx::new()));
|
push_stack(gc, loc, StackEntryKind::Outline(OutlineCtx::new()));
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user