Skip to content
Snippets Groups Projects
Commit 0dd27c0b authored by Andreas Kraft's avatar Andreas Kraft
Browse files

Improved printing

parent 45b89e6a
Branches
No related tags found
No related merge requests found
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
result to stdout. result to stdout.
""" """
_print = print # save the original print function
from rich import print
import argparse, sys import argparse, sys
from markdownTools import analyseMarkdown, setLoggers from markdownTools import analyseMarkdown, setLoggers
...@@ -27,7 +29,7 @@ def main() -> None: ...@@ -27,7 +29,7 @@ def main() -> None:
error=lambda m: print(f'[red]{m}', file=sys.stderr) if args.verbose else 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 # 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__': if __name__ == '__main__':
......
...@@ -484,7 +484,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR ...@@ -484,7 +484,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR
# Check if there are any data rows # Check if there are any data rows
if not dataRows and not headerRows: 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 # Format text
for gridRows in [headerRows, dataRows]: for gridRows in [headerRows, dataRows]:
...@@ -538,7 +538,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR ...@@ -538,7 +538,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR
colspan += 1 colspan += 1
if not sum == numberOfColumns: 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 # Checking the data rows
forwardRowspan = [] forwardRowspan = []
...@@ -561,7 +561,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR ...@@ -561,7 +561,7 @@ def parseGridTableWithSpans(gridTable:str) -> tuple[GridTableRowList, GridTableR
colspan += 1 colspan += 1
if not sum == numberOfColumns: 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 return headerRows, dataRows
......
...@@ -429,6 +429,7 @@ def analyseMarkdown(filename:Optional[str]=None, inLines:Optional[list[str]]=Non ...@@ -429,6 +429,7 @@ def analyseMarkdown(filename:Optional[str]=None, inLines:Optional[list[str]]=Non
printDebug(htmltable) printDebug(htmltable)
except Exception as e: except Exception as e:
printError(f"Error: {e}") printError(f"Error: {e}")
htmltable = f'<mark>Conversion error: {e}</mark>\n'
outClauses[-1].append(Line(htmltable, LineType.RAWHTML)) outClauses[-1].append(Line(htmltable, LineType.RAWHTML))
gridTable = '' gridTable = ''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment