From c70b2c4154d9b6e46f282c1f212c52e9fbfa5a07 Mon Sep 17 00:00:00 2001 From: Isaac Muse Date: Thu, 19 Jan 2017 06:51:06 -0700 Subject: Tables: Improvements (#530) Tables now handle escaped pipes when testing, in table borders, and in the inline content. To achieve properly, a bug had to be fixed related to appending escaped chars to the Markdown class. Now appended chars only appear in the current instance. Lastly the first backtick in a table can be escaped rounding out the last corner case. --- tests/extensions/extra/tables.html | 74 +++++++++++++++++++++++++++++++++++++- tests/extensions/extra/tables.txt | 31 ++++++++++++++++ tests/test_apis.py | 12 +++++++ 3 files changed, 116 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/extensions/extra/tables.html b/tests/extensions/extra/tables.html index a0b1f71..b81582c 100644 --- a/tests/extensions/extra/tables.html +++ b/tests/extensions/extra/tables.html @@ -284,4 +284,76 @@ Content Cell | Content Cell \ - \ No newline at end of file + +

Only the first backtick can be escaped

+ + + + + + + + + + + + + +
EscapedBacticks
`\``
+

Test escaped pipes

+ + + + + + + + + + + + + +
Column 1Column 2
| |Pipes are okay in code and escaped. |
+ + + + + + + + + + + + + + + + + +
Column 1Column 2
row1row1 |
row2row2
+

Test header escapes

+ + + + + + + + + + + + + + + + + +
`\ |\ |
row1row1
row2row2
+

Escaped pipes in format row should not be a table

+

| Column1 | Column2 | +| ------- || ------- | +| row1 | row1 | +| row2 | row2 |

\ No newline at end of file diff --git a/tests/extensions/extra/tables.txt b/tests/extensions/extra/tables.txt index a9677ba..d5bd6ea 100644 --- a/tests/extensions/extra/tables.txt +++ b/tests/extensions/extra/tables.txt @@ -90,3 +90,34 @@ Odd backticks | Even backticks Escapes | More Escapes ------- | ------ `` `\`` | `\` + +Only the first backtick can be escaped + +Escaped | Bacticks +------- | ------ +\`` \` | \`\` + +Test escaped pipes + +Column 1 | Column 2 +-------- | -------- +`|` \| | Pipes are okay in code and escaped. \| + +| Column 1 | Column 2 | +| -------- | -------- | +| row1 | row1 \| +| row2 | row2 | + +Test header escapes + +| `` `\`` \| | `\` \| +| ---------- | ---- | +| row1 | row1 | +| row2 | row2 | + +Escaped pipes in format row should not be a table + +| Column1 | Column2 | +| ------- \|| ------- | +| row1 | row1 | +| row2 | row2 | diff --git a/tests/test_apis.py b/tests/test_apis.py index e3de779..7b1214f 100644 --- a/tests/test_apis.py +++ b/tests/test_apis.py @@ -758,3 +758,15 @@ PLACE_MARKER= ~~~footnotes~~~ """ self.create_config_file(config) self.assertRaises(yaml.YAMLError, parse_options, ['-c', self.tempfile]) + + +class TestEscapeAppend(unittest.TestCase): + """ Tests escape character append. """ + + def testAppend(self): + """ Test that appended escapes are only in the current instance. """ + md = markdown.Markdown() + md.ESCAPED_CHARS.append('|') + self.assertEqual('|' in md.ESCAPED_CHARS, True) + md2 = markdown.Markdown() + self.assertEqual('|' not in md2.ESCAPED_CHARS, True) -- cgit v1.2.3