From: Daniel O. <do...@us...> - 2017-11-11 05:25:54
|
--- ** [bugs:#333] Simple Table: Double Spaced Columns Throws TableMarkupError** **Status:** open **Group:** Default **Created:** Sat Nov 11, 2017 05:25 AM UTC by Daniel Oakey **Last Updated:** Sat Nov 11, 2017 05:25 AM UTC **Owner:** nobody Consider the following code: ```python import docutils.statemachine import docutils.parsers.rst.tableparser import pprint def simple2data(text): '''Convert a simple table to data''' text = text.strip() lines = text.split('\n') for i in range(len(lines)): lines[i] = lines[i].strip() parser = docutils.parsers.rst.tableparser.SimpleTableParser() block = docutils.statemachine.StringList(list(lines)) simple_data = parser.parse(block) pprint.pprint(simple_data) text = ''' ===== ===== ====== A B A or B ===== ===== ====== False False False True False True False True True True True True ===== ===== ====== ''' simple2data(text) ``` The simple table should be parsed, but docutils throws an error: ``` Traceback (most recent call last): File "simple2data.py", line 68, in <module> simple2data(text) File "simple2data.py", line 18, in simple2data simple_data = parser.parse(block) File "docutils/parsers/rst/tableparser.py", line 67, in parse self.parse_table() File "docutils/parsers/rst/tableparser.py", line 411, in parse_table (line.rstrip(), offset)) File "docutils/parsers/rst/tableparser.py", line 484, in parse_row self.check_columns(lines, start, columns) File "docutils/parsers/rst/tableparser.py", line 523, in check_columns offset=first_line+offset) docutils.parsers.rst.tableparser.TableMarkupError: Text in column margin in table line 2. ``` If you change line 520 in docutils/parsers/rst/tableparser.py like this: elif line[end+1:nextstart].strip(): It seems to fix this issue. --- Sent from sourceforge.net because doc...@li... is subscribed to https://sourceforge.net/p/docutils/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |