Correct table header parsing

This commit is contained in:
RunasSudo 2019-09-11 11:30:27 +10:00
parent 245a5ee46e
commit 5255296dba
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -193,7 +193,7 @@ class TableRow(mistletoe.block_token.BlockToken):
self.label = self.children[0].label self.label = self.children[0].label
class TableCell(mistletoe.block_token.BlockToken): class TableCell(mistletoe.block_token.BlockToken):
pattern1 = re.compile(r'\s*([0-9A-Za-z]+\s+)?(\[[0-9]+\])?(.*)') pattern1 = re.compile(r'\s*(?:([0-9A-Za-z]+)(?:\[([0-9]+)\])?\s+)?(.*)')
def __init__(self, inner, row, colnum, align=None): def __init__(self, inner, row, colnum, align=None):
self.row = row self.row = row
@ -204,7 +204,7 @@ class TableCell(mistletoe.block_token.BlockToken):
label, weight, content = self.pattern1.match(inner).group(1, 2, 3) label, weight, content = self.pattern1.match(inner).group(1, 2, 3)
self.label = label.strip() if label else None self.label = label.strip() if label else None
self.weight = int(weight[1:-1]) if weight else 1 self.weight = int(weight) if weight else 1
self.children = mistletoe.span_token.tokenize_inner(content) self.children = mistletoe.span_token.tokenize_inner(content)
else: else:
self.label = None self.label = None