parse table cell spans in cmark and use the information - #74
Merged
Conversation
rdar://98017807
Contributor
Author
|
@swift-ci Please test |
3 tasks
Comment on lines
+983
to
+994
| let colspan = headCellSpans[column] | ||
| if colspan == 0 { | ||
| // If this cell is being spanned over, collapse it so it | ||
| // can be filled with the spanning cell. | ||
| return "" | ||
| } else { | ||
| // With a colspan, we want to expand the cell width to | ||
| // cover multiple columns. This helpfully generalizes | ||
| // to `colspan == 1`, where it will only query the | ||
| // current column! | ||
| let lastColumn = column + Int(colspan) | ||
| let minLineLength = (column..<lastColumn).map({ finalColumnWidths[$0] }).reduce(0, { $0 + $1 }) |
There was a problem hiding this comment.
�Should this logic be refactored?
Contributor
Author
There was a problem hiding this comment.
Good idea! Just pushed up a new commit combining the logic.
Contributor
Author
|
@swift-ci Please test |
daniel-grumberg
self-requested a review
September 21, 2022 10:07
daniel-grumberg
approved these changes
Sep 21, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug/issue #, if applicable: rdar://98017807
Summary
This PR adds support for swift-cmark's new table row- and column-spanning syntax and enables it by default. (A syntax overview is written up in the linked PR's description.) The spanning values are exposed as properties on the
Table.Cellstruct, with the following semantics:Support has been added in Swift-Markdown's Markdown reformatter and its debug tree representation to properly process the new information.
Dependencies
swiftlang/swift-cmark#46 (already merged)
Testing
Use the following sample Markdown table, showcasing the new syntax:
Steps:
swift run markdown-tool dump-tree test.mdChecklist
Make sure you check off the following items. If they cannot be completed, provide a reason.
./bin/testscript and it succeeded