Skip to content

Commit b3f2eae

Browse files
committed
Add the H and RP structure roles
1 parent 5999e72 commit b3f2eae

1 file changed

Lines changed: 32 additions & 10 deletions

File tree

src/structure.rs

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,8 @@ pub enum StructRole {
792792
Private,
793793
/// A paragraph
794794
P,
795+
/// A strongly structured heading.
796+
StructuredHeading,
795797
/// First-level heading.
796798
H1,
797799
/// Second-level heading.
@@ -881,6 +883,7 @@ impl StructRole {
881883
Self::NonStruct => Name(b"NonStruct"),
882884
Self::Private => Name(b"Private"),
883885
Self::P => Name(b"P"),
886+
Self::StructuredHeading => Name(b"H"),
884887
Self::H1 => Name(b"H1"),
885888
Self::H2 => Name(b"H2"),
886889
Self::H3 => Name(b"H3"),
@@ -936,6 +939,7 @@ impl StructRole {
936939
Self::NonStruct => Some(StructRole2::NonStruct),
937940
Self::Private => None,
938941
Self::P => Some(StructRole2::P),
942+
Self::StructuredHeading => Some(StructRole2::StructuredHeading),
939943
Self::H1 => Some(StructRole2::Heading(NonZeroU16::new(1).unwrap())),
940944
Self::H2 => Some(StructRole2::Heading(NonZeroU16::new(2).unwrap())),
941945
Self::H3 => Some(StructRole2::Heading(NonZeroU16::new(3).unwrap())),
@@ -989,19 +993,23 @@ impl StructRole {
989993
| Self::Index
990994
| Self::NonStruct
991995
| Self::Private => StructRoleType::Grouping,
992-
Self::P | Self::H1 | Self::H2 | Self::H3 | Self::H4 | Self::H5 | Self::H6 => {
996+
Self::P
997+
| Self::StructuredHeading
998+
| Self::H1
999+
| Self::H2
1000+
| Self::H3
1001+
| Self::H4
1002+
| Self::H5
1003+
| Self::H6 => {
9931004
StructRoleType::BlockLevel(BlockLevelRoleSubtype::ParagraphLike)
9941005
}
9951006
Self::L | Self::LI | Self::Lbl | Self::LBody => {
9961007
StructRoleType::BlockLevel(BlockLevelRoleSubtype::List)
9971008
}
998-
Self::Table
999-
| Self::TR
1000-
| Self::TH
1001-
| Self::TD
1002-
| Self::THead
1003-
| Self::TBody
1004-
| Self::TFoot => StructRoleType::BlockLevel(BlockLevelRoleSubtype::Table),
1009+
Self::Table => StructRoleType::BlockLevel(BlockLevelRoleSubtype::Table),
1010+
Self::TR | Self::TH | Self::TD | Self::THead | Self::TBody | Self::TFoot => {
1011+
StructRoleType::Table
1012+
}
10051013
Self::Span
10061014
| Self::Quote
10071015
| Self::Note
@@ -1036,6 +1044,8 @@ pub enum StructRoleType {
10361044
InlineLevel(InlineLevelRoleSubtype),
10371045
/// Elements whose contents consist of one or more graphics objects.
10381046
Illustration,
1047+
/// Elements that occur in a table, such as rows and cells.
1048+
Table,
10391049
}
10401050

10411051
/// Subtypes of block-level structure roles, determining the layout and
@@ -1126,6 +1136,8 @@ pub enum StructRole2 {
11261136
RB,
11271137
/// Annotation text of a Ruby annotation.
11281138
RT,
1139+
/// Punctuation in a Ruby annotation.
1140+
RP,
11291141
/// Warichu annotation for CJK text.
11301142
Warichu,
11311143
/// Text of a Warichu annotation.
@@ -1193,6 +1205,7 @@ impl StructRole2 {
11931205
Self::Ruby => b"Ruby",
11941206
Self::RB => b"RB",
11951207
Self::RT => b"RT",
1208+
Self::RP => b"RP",
11961209
Self::Warichu => b"Warichu",
11971210
Self::WT => b"WT",
11981211
Self::WP => b"WP",
@@ -1252,7 +1265,9 @@ impl StructRole2 {
12521265
StructRole::P
12531266
},
12541267
),
1255-
Self::StructuredHeading => StructRole2Compat::RoleMapping(StructRole::P),
1268+
Self::StructuredHeading => {
1269+
StructRole2Compat::Compatible(StructRole::StructuredHeading)
1270+
}
12561271
Self::Title => StructRole2Compat::RoleMapping(
12571272
if opts.contains(RoleMapOpts::map_title_to_h1) {
12581273
StructRole::H1
@@ -1278,6 +1293,7 @@ impl StructRole2 {
12781293
Self::Ruby => StructRole2Compat::Compatible(StructRole::Ruby),
12791294
Self::RB => StructRole2Compat::Compatible(StructRole::RB),
12801295
Self::RT => StructRole2Compat::Compatible(StructRole::RT),
1296+
Self::RP => StructRole2Compat::Compatible(StructRole::RP),
12811297
Self::Warichu => StructRole2Compat::Compatible(StructRole::Warichu),
12821298
Self::WT => StructRole2Compat::Compatible(StructRole::WT),
12831299
Self::WP => StructRole2Compat::Compatible(StructRole::WP),
@@ -1320,7 +1336,13 @@ impl StructRole2 {
13201336
| Self::Form => {
13211337
StructRoleType2::InlineLevel(InlineLevelRoleSubtype2::Generic)
13221338
}
1323-
Self::Ruby | Self::RB | Self::RT | Self::Warichu | Self::WT | Self::WP => {
1339+
Self::Ruby
1340+
| Self::RB
1341+
| Self::RP
1342+
| Self::RT
1343+
| Self::Warichu
1344+
| Self::WT
1345+
| Self::WP => {
13241346
StructRoleType2::InlineLevel(InlineLevelRoleSubtype2::RubyWarichu)
13251347
}
13261348
Self::L | Self::LI | Self::LBody => StructRoleType2::List,

0 commit comments

Comments
 (0)