Render basic tables and detect them in rules#507
Render basic tables and detect them in rules#507masonium wants to merge 11 commits intodaisy:mainfrom
Conversation
Any thoughts? |
|
Using frame, etc., is a good idea and will work for legacy MathML so we should keep it. However, in MathML core (which is the future), mtable are supposed to be styled with CSS so that info won't likely be around unless it is a local CSS style ( One option is to look at the parent of the table and see if has delimiters around it (parens, brackets, vertical bars, double vertical bars, ???). Comments on the code:
xpath-functions.rs:
mtable.rs:
|
find rowspan or colspan attributes only on children and grandchildren of mtable element
rowspan and colspan/columnspan are fully handled as dictated by MathML descriptions. Empty rows and cells are properly accounted for.
|
I'll try to address everything. For code-specific comments, it's probably easier for both of us to use the commenting feature on Github (pressing the + next to the line numbers on the diffs) so that it's a bit easier to track individual threads.
I'll play around with looking for delimiters.
I wanted to debug some of the functions that take a
It shouldn't be. Fixed.
Fixed. For what it's worth, the existing code also contains some mix of tabs and spaces (see
I adjusted the code so it does a more thorough accounting here, now that I've read the MathML spec and have a reasonable handle on this. One caveat is that, though the spec doesn't seem to fully address it, extra rows that are implied by a dangling The column count is more explicitly defined as the maximum across all rows.
I still need to add these. |
|
I think @NSoiffer 's suggestion about delimeters is good |
| // Other elements should be ignored. | ||
| let row_name = name(row); | ||
|
|
||
| let row_type = if row_name == "mlabeledtr" { |
There was a problem hiding this comment.
I'm not sure if "if row_name== "..." then ... else if ... " or
let row_type = match row_name {
"mlabeledtr" => CTDRowType::Labeled,
"mtr" => CTDRowType::Normal,
"mtd" => CTDRowType::Implicit,
_ => continue,
};
is more idiomatic. It's fine to leave it as is, but I'm throwing that out as alternative as I think I've seen "match" used more often in Rust code.
| /// ignored. The number of columns is determined only from the first | ||
| /// row, if it exists. Within that row, non-`mtd` elements are ignored. | ||
| fn count_table_dims<'d>(mut self, e: Element<'_>) -> Result<(Value<'d>, Value<'d>), Error> { | ||
| for child in e.children() { |
There was a problem hiding this comment.
Maybe I missed it, but I don't think anywhere is checking
name(e) == "mtable"
|
Apologies for not using the code comment feature. I did this time. In general, it looks much better. The logic is more complicated, so I feel less sure that I can be confident with my review. Adding some more tests, both unit tests with various rowspan/columnspan settings, and some speech tests would add confidence that the code is correct. A few tests for cases when row/columnspan overlap would be very useful since that is a tricky case. |
Addresses issue #283 .
This PR adds some internal functions to compute table dimensions (rows and columns) taking
rowspans andcolspans into account, and uses them to render tables with the:arrayintent as "table with m rows and n columns".I'm not super happy with the current logic to detect that an unspecified
mtableshould have an:arrayintent. Right now, it assumes that anymtablethat either renders its frame assolidordashedor has anmrowormtdthat specifies arowspanorcolspanshould be an:array. I think we want something more general, though.