Skip to content

Commit 7cb5d3d

Browse files
committed
Support attr on the element that starts a subtable
1 parent 59edf76 commit 7cb5d3d

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,8 @@ fn process_event(event: &Event, mut state: &mut State) -> Step {
683683
else if state.path.len() >= table.path.len() {
684684
if state.path == table.path { state.table.lastid.borrow_mut().clear(); }
685685
if state.path == state.rowpath { state.fullcount += 1; }
686+
let mut subtable = None;
687+
686688
for i in 0..table.columns.len() {
687689
if state.path == table.columns[i].path { // This start tag matches one of the defined columns
688690
// Handle the 'seri' case where this column is a virtual auto-incrementing serial
@@ -698,10 +700,8 @@ fn process_event(event: &Event, mut state: &mut State) -> Step {
698700
}
699701
// Handle 'subtable' case (the 'cols' entry has 'cols' of its own)
700702
if table.columns[i].subtable.is_some() {
701-
state.tables.push(table);
702-
state.parentcol = Some(&table.columns[i]);
703-
state.table = table.columns[i].subtable.as_ref().unwrap();
704-
return Step::Repeat; // Continue the repeat loop because a subtable column may also match the current path
703+
if subtable.is_some() { fatalerr!("Error: multiple subtables starting from the same element is not supported"); }
704+
subtable = Some(i);
705705
}
706706
// Handle the 'attr' case where the content is read from an attribute of this tag
707707
if let Some(request) = table.columns[i].attr {
@@ -741,6 +741,12 @@ fn process_event(event: &Event, mut state: &mut State) -> Step {
741741
}
742742
}
743743
}
744+
if let Some(i) = subtable {
745+
state.tables.push(table);
746+
state.parentcol = Some(&table.columns[i]);
747+
state.table = table.columns[i].subtable.as_ref().unwrap();
748+
return Step::Repeat; // Continue the repeat loop because a subtable column may also match the current path
749+
}
744750
}
745751
},
746752
Event::Text(ref e) => {

0 commit comments

Comments
 (0)