Changed the table base implementation
This commit is contained in:
parent
e3f41eee43
commit
3e92f661f4
|
|
@ -424,8 +424,8 @@ _to_container = {
|
|||
"hyperlink": HyperLinkContainer,
|
||||
"linebreak": LinebreakContainer,
|
||||
"table:row": TableRowContainer,
|
||||
"table:cell": TableCellContainer,
|
||||
"table:separator": TableSeparatorContainer,
|
||||
"table:cell": TableCellContainer, # Should be an error I beleive ?
|
||||
"table:separator": TableSeparatorContainer, # Should be an error I beleive ?
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -456,6 +456,10 @@ class ContextManager:
|
|||
"blockquotes": [], # future: Implement blockquotes
|
||||
"linebreak": ["linebreak"],
|
||||
}
|
||||
self.dict_lookahead_reparse = [
|
||||
"list:ulist",
|
||||
"list:olist",
|
||||
]
|
||||
self.contextualised = False
|
||||
|
||||
def encapsulate(self, start, end):
|
||||
|
|
@ -649,12 +653,14 @@ class ContextManager:
|
|||
"""
|
||||
range_to_encapsulate = 0
|
||||
line_skipped = 0
|
||||
self.recontext(self.parsed_list[index])
|
||||
if self.parsed_list[index].label in self.dict_lookahead_reparse:
|
||||
self.recontext(self.parsed_list[index])
|
||||
i = index + 1
|
||||
|
||||
while i < len(self.parsed_list):
|
||||
if self.parsed_list[i].label in self.dict_lookahead[token.label]:
|
||||
self.recontext(self.parsed_list[i])
|
||||
if self.parsed_list[i].label in self.dict_lookahead_reparse:
|
||||
self.recontext(self.parsed_list[i])
|
||||
self.pile.append(self.parsed_list[i])
|
||||
range_to_encapsulate += 1
|
||||
elif self.parsed_list[i].label == "linebreak":
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ class TableToken(SemanticType):
|
|||
label = "table"
|
||||
|
||||
|
||||
class TableRowToken(SemanticType):
|
||||
class TableRowToken(FinalSemanticType, TokensToMatch):
|
||||
label = "table:row"
|
||||
|
||||
|
||||
|
|
@ -291,6 +291,10 @@ class TableSeparatorToken(SemanticType):
|
|||
label = "table:separator"
|
||||
|
||||
|
||||
class TableCellSizeToken(SemanticType):
|
||||
label = "table:cell_size"
|
||||
|
||||
|
||||
class OptionalToken(SemanticType):
|
||||
label = "optional"
|
||||
|
||||
|
|
@ -499,7 +503,7 @@ se_end = (structural_elements + pps('>>')).add_parse_action(of_type(StructuralEl
|
|||
se = se_end | se_start # Structural element
|
||||
table_row = pp.OneOrMore(
|
||||
# pp.Regex(r'\|(\d)?')('table_colspan') +
|
||||
(pp.Combine(pps('|') + pp.Word(pp.nums)('table_colspan')) | pps('|')) +
|
||||
(pp.Combine(pps('|') + pp.Word(pp.nums))('table_colspan').add_parse_action(of_type(TableCellSizeToken)) | pps('|')) +
|
||||
pp.SkipTo('|')('table_cell').add_parse_action(reparse(enhanced_text), of_type(TableCellToken))
|
||||
).add_parse_action(of_type(TableRowToken)) + pps('|') + pp.Opt(optional)
|
||||
table_separator = pp.OneOrMore(
|
||||
|
|
|
|||
Loading…
Reference in New Issue