Skip to content

Commit 0daa403

Browse files
author
vidy
committed
Refacter the way to get node tag
1 parent e68b23d commit 0daa403

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/flow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub(crate) fn build<E: Encoder>(mut flow: &mut Flow, spans: &[TextSpan<E>], node
268268
});
269269
para_start = line_start;
270270
}
271-
//Always add a line break for new line, which will be treated as whitespace in concat_text method
271+
//Always add a line break for new line, which will be treated as whitespace in the concat_text method
272272
text.push('\n');
273273
}
274274
if end > line_start {

src/node.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,10 @@ fn split<E: Encoder>(boxes: &mut [(RectF, usize)], spans: &[TextSpan<E>], lines:
200200
}
201201
}
202202

203-
let tag = if y_gaps.len() == 0 {
204-
if cells.iter().all(|n| n.tag() <= NodeTag::Line) {
205-
NodeTag::Line
206-
} else {
207-
NodeTag::Complex
208-
}
209-
} else if x_gaps.len() == 0 {
210-
if cells.iter().all(|n| n.tag() <= NodeTag::Line) {
211-
NodeTag::Paragraph
212-
} else {
213-
NodeTag::Complex
214-
}
215-
} else {
216-
NodeTag::Complex
203+
let tag = match (y_gaps.is_empty(), x_gaps.is_empty()) {
204+
(true, _) if cells.iter().all(|n| n.tag() <= NodeTag::Line) => NodeTag::Line,
205+
(_, true) if cells.iter().all(|n| n.tag() <= NodeTag::Line) => NodeTag::Paragraph,
206+
_ => NodeTag::Complex
217207
};
218208

219209
Node::Grid {

0 commit comments

Comments
 (0)