Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements parsing and repairing formatted ascii tables #37

Closed
wants to merge 13 commits into from

Conversation

dwesely
Copy link
Contributor

@dwesely dwesely commented Sep 15, 2018

Implements parsing and repairing formatted ascii tables (#31 and #33), user can select the input style, or use "attempt auto-detect" to try and guess the input style, it seems to work pretty well for the test cases I tried. This successfully repairs the test case described in #31. You can output in the same format, or convert to any of the other output formats, with or without the header option.

Effects on the items from pull request #36:
Contains Prefix option for output RE: #35, but the comment prefixes are not compatible with input style options yet, if that's even a desired feature.
Supports output to reStructuredText Grid style RE: #32, simple tables can be parsed successfully to convert table formats, but the input parser still chokes on the multi-row spanning table example:

+------------------------+------------+----------+----------+
| Header row, column 1   | Header 2   | Header 3 | Header 4 |
| (header rows optional) |            |          |          |
+========================+============+==========+==========+
| body row 1, column 1   | column 2   | column 3 | column 4 |
+------------------------+------------+----------+----------+
| body row 2             | Cells may span columns.          |
+------------------------+------------+---------------------+
| body row 3             | Cells may  | - Table cells       |
+------------------------+ span rows. | - contain           |
| body row 4             |            | - body elements.    |
+------------------------+------------+---------------------+

dwesely and others added 13 commits July 14, 2016 20:42
Updating my base fork
Added line breaks and tabs to HTML output so the results are a bit easier to read in the output textarea.
First pass at implementing @rhys0178 cookie saving. Haven't got it working locally yet, and I'd like to save/load the parameters to the cookie too before committing this to the main branch.
The output auto-populates, so swapped the "Create" button out for a "Reset" button that would clear user preferences and reload the default.
ReStructuredText Grid format uses a different separator for the top and bottom of the header, the assumption has been that the header top and bottom are the same when both are present. A more robust solution could be to define headerTop, headerBottom, and bodyBottom horizontal character definitions for each style.

Reddit has no left or right side lines, but has vertical separators in the middle, which was also new. A more robust solution could be to define headerLeft, headerRight, bodyLeft, and bodyRight vertical character definitions for each style.
ReStructuredText Grid format uses a different separator for the top and bottom of the header, the assumption has been that the header top and bottom are the same when both are present. A more robust solution could be to define headerTop, headerBottom, and bodyBottom horizontal character definitions for each style.

Reddit has no left or right side lines, but has vertical separators in the middle, which was also new. A more robust solution could be to define headerLeft, headerRight, bodyLeft, and bodyRight vertical character definitions for each style.
… table into code.

Pulled out the separator line generator to its own function to reduce redundant code.

Added map of the border style variables in script.js for reference.
Some styles over-ride the prefix/suffix (wikimedia, specifically). Moved prefix definition earlier to allow border style to null out the prefix/suffix.
@ozh
Copy link
Owner

ozh commented Sep 16, 2018

Dude, I'm blindly merging your two PR. There are so much changes it's practically impossible to review. Pro tip for future PR on any project : please be more atomic, ie a PR for cookie implementation, a PR for tweaking style, and so on.

@ozh
Copy link
Owner

ozh commented Sep 16, 2018

Cannot merge actually, script.js is conflicting

@dwesely
Copy link
Contributor Author

dwesely commented Sep 17, 2018

Sorry about that, guess I got a little carried away. :-) I'll close the request and resubmit more sensically.

@dwesely dwesely closed this Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants