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

Fix tests #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

hughdavenport
Copy link
Contributor

Fixes #6.

Also fixes #3.

Also fixes GovReady#3.

Checks whether the next nonspace is None which means that it is a blank line.

Alters the test case to fit in with the Google Flavoured Markdown (GFM) spec.
Removes extraneous cells if more columns than header row.
This makes a few changes
- The `table` function in `BlockStarts` returns 2 now
 - Returning 2 now sets `matched_leaf = True` in `commonmark`, which a
   table is a leaf node in markdown
 - I found this meant that it didn't slurp up the whitespace on the
   first line, yet still passed all the tests.
- Add the pipe symbol back to the start of each line after slurping
  in `node.string_content`
- In the `finalize` function, ignore the first pipe on the line
  (keeping the same functionality of before when it got slurped)
- Also in `finalize`, if a mix-match between the delimiter row and the
  header row is found, set the node type to `paragraph`
  N.B. This doesn't change the underlying python object type, just sets
  `block.t = 'paragraph` which appears to work on rendering
@@ -141,6 +143,7 @@ def test_break2(self):
</tr>
</tbody>
</table>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This differs slightly from the spec, but doesn't actually change the visual output of the html (as blank lines aren't treated specially).

If you are bothered by this, let me know and I can try work out why the new line appears and whether we can avoid it.

@@ -107,6 +117,9 @@ def finalize(parser=None, block=None):
if len(list(filter(lambda cell : not re.match(r"[-=:]+$", cell), row))) == 0:
# This row has cells of just dahses.
if len(table_parts) == 1:
if len(row) != len(table_parts[0][0]):
block.t = 'paragraph'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in commit message, this doesn't actually change the Python type of the block, but it does produce the right output on rendering so likely doesn't matter.

@@ -25,7 +25,8 @@ def table(parser, container):
parser.advance_offset(1, False)
parser.close_unmatched_blocks()
parser.add_child('table', parser.next_nonspace)
return 1
parser.tip.string_content = '|'
return 2
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning 2 makes it a leaf node, which in practice means that it doesn't slurp up whitespace after the |, meaning the pipe can be added back simply.

@hughdavenport
Copy link
Contributor Author

Fixes #2

@hughdavenport
Copy link
Contributor Author

My latest PR (#11) may have broken this. Have not tested

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.

Tests failing End of table (e.g. </tr></table>) does not get generated.
1 participant