`.
- let level = self.resolve_level(styles);
- let t = [tag::h2, tag::h3, tag::h4, tag::h5, tag::h6][level.get().min(5) - 1];
- HtmlElem::new(t).with_body(Some(realized)).pack().spanned(span)
+ let level = self.resolve_level(styles).get();
+ if level >= 6 {
+ engine.sink.warn(warning!(span,
+ "heading of level {} was transformed to \
+
, which is not \
+ supported by all assistive technology",
+ level, level + 1;
+ hint: "HTML only supports
to , not ", level + 1;
+ hint: "you may want to restructure your document so that \
+ it doesn't contain deep headings"));
+ HtmlElem::new(tag::div)
+ .with_body(Some(realized))
+ .with_attr(attr::role, "heading")
+ .with_attr(attr::aria_level, eco_format!("{}", level + 1))
+ .pack()
+ .spanned(span)
+ } else {
+ let t = [tag::h2, tag::h3, tag::h4, tag::h5, tag::h6][level - 1];
+ HtmlElem::new(t).with_body(Some(realized)).pack().spanned(span)
+ }
} else {
let realized = BlockBody::Content(realized);
BlockElem::new().with_body(Some(realized)).pack().spanned(span)