diff --git a/toMkdocs/gridTableFilter.py b/toMkdocs/gridTableFilter.py index 027c69f8e2695740c14877d62ef757b2a474eea3..0f1112d2946dbe7ce4f70fa1c2d5915cdb02b35e 100644 --- a/toMkdocs/gridTableFilter.py +++ b/toMkdocs/gridTableFilter.py @@ -11,6 +11,8 @@ result to stdout. """ +_print = print # save the original print function +from rich import print import argparse, sys from markdownTools import analyseMarkdown, setLoggers @@ -27,7 +29,7 @@ def main() -> None: error=lambda m: print(f'[red]{m}', file=sys.stderr) if args.verbose else None) # Read the input from stdin and write the result to stdout - print(analyseMarkdown(inLines=sys.stdin.readlines()), file=sys.stdout) + _print(analyseMarkdown(inLines=sys.stdin.readlines()), file=sys.stdout) if __name__ == '__main__': diff --git a/toMkdocs/gridTableTools.py b/toMkdocs/gridTableTools.py index 6b4161cc25b50129bcd4253bb174d927d3cd9647..8c37901df3675ca22eeb8056022e35fa8c08bf50 100644 --- a/toMkdocs/gridTableTools.py +++ b/toMkdocs/gridTableTools.py @@ -484,7 +484,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR # Check if there are any data rows if not dataRows and not headerRows: - raise ValueError('No valid rows found in the provided grid table.') + raise ValueError('No valid rows found in the provided grid table. Wrong format of line separator?') # Format text for gridRows in [headerRows, dataRows]: @@ -538,7 +538,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR colspan += 1 if not sum == numberOfColumns: - raise ValueError('Grid table not converted properly') + raise ValueError(f'Grid table not converted properly. Number of columns in header row {idx} is {sum} instead of {numberOfColumns}') # Checking the data rows forwardRowspan = [] @@ -561,7 +561,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR colspan += 1 if not sum == numberOfColumns: - raise ValueError('Grid table not converted properly') + raise ValueError(f'Grid table not converted properly. Number of columns in data row {idx} is {sum} instead of {numberOfColumns}') return headerRows, dataRows diff --git a/toMkdocs/markdownTools.py b/toMkdocs/markdownTools.py index 67fafa5b0b6aa8a34082f7c207c5867c58b754db..783c0c202d886829f7cee412e2a442fcddeee5cf 100644 --- a/toMkdocs/markdownTools.py +++ b/toMkdocs/markdownTools.py @@ -429,6 +429,7 @@ def analyseMarkdown(filename:Optional[str]=None, inLines:Optional[list[str]]=Non printDebug(htmltable) except Exception as e: printError(f"Error: {e}") + htmltable = f'<mark>Conversion error: {e}</mark>\n' outClauses[-1].append(Line(htmltable, LineType.RAWHTML)) gridTable = ''