Skip to content

Last cell of table missing if blank #118

@JohnPickerill

Description

@JohnPickerill

If the last table of a cell is blank then it is missing in the rendered HTML.
This appears to be because the last pipe is removed to avoid an extra row being created if by the split function.
A crude fix to this would look something like

def parse_table(self, m):
    item = self._process_table(m)
    #JP fix for blank last cell in table
    rmat = re.match(r'^(.*)(?<=\|)(.*)\|\s*\n$',m.group(3),re.S)
    if  rmat:
        if rmat.group(2).strip() == '':
            cells = rmat.group(1) +'|'
        else:               
            cells = rmat.group(1) + rmat.group(2) 
    # original
    #cells = re.sub(r'(?: *\| *)?\n$', '', m.group(3))
    logger_m.debug(cells)

    cells = cells.split('\n')
    for i, v in enumerate(cells):
        v = re.sub(r'^ *\| *| *\| *$', '', v)
        cells[i] = re.split(r' *\| *', v)

    item['cells'] = cells
    self.tokens.append(item) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions