Unverified Commit ac5db5d4 authored by Xiaomeng Zhao's avatar Xiaomeng Zhao Committed by GitHub
Browse files

Merge pull request #2729 from Carkham/dev

Fix otsl to html conversion
parents c47faa4d 0031981e
...@@ -132,6 +132,35 @@ def otsl_parse_texts(texts, tokens): ...@@ -132,6 +132,35 @@ def otsl_parse_texts(texts, tokens):
r_idx = 0 r_idx = 0
c_idx = 0 c_idx = 0
# Check and complete the matrix
if split_row_tokens:
max_cols = max(len(row) for row in split_row_tokens)
# Insert additional <ecel> to tags
for row_idx, row in enumerate(split_row_tokens):
while len(row) < max_cols:
row.append(OTSL_ECEL)
# Insert additional <ecel> to texts
new_texts = []
text_idx = 0
for row_idx, row in enumerate(split_row_tokens):
for col_idx, token in enumerate(row):
new_texts.append(token)
if text_idx < len(texts) and texts[text_idx] == token:
text_idx += 1
if (text_idx < len(texts) and
texts[text_idx] not in [OTSL_NL, OTSL_FCEL, OTSL_ECEL, OTSL_LCEL, OTSL_UCEL, OTSL_XCEL]):
new_texts.append(texts[text_idx])
text_idx += 1
new_texts.append(OTSL_NL)
if text_idx < len(texts) and texts[text_idx] == OTSL_NL:
text_idx += 1
texts = new_texts
def count_right(tokens, c_idx, r_idx, which_tokens): def count_right(tokens, c_idx, r_idx, which_tokens):
span = 0 span = 0
c_idx_iter = c_idx c_idx_iter = c_idx
...@@ -235,10 +264,11 @@ def export_to_html(table_data: TableData): ...@@ -235,10 +264,11 @@ def export_to_html(table_data: TableData):
body = "" body = ""
grid = table_data.grid
for i in range(nrows): for i in range(nrows):
body += "<tr>" body += "<tr>"
for j in range(ncols): for j in range(ncols):
cell: TableCell = table_data.grid[i][j] cell: TableCell = grid[i][j]
rowspan, rowstart = ( rowspan, rowstart = (
cell.row_span, cell.row_span,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment