diff --git a/toMkdocs/gridTableFilter.py b/toMkdocs/gridTableFilter.py new file mode 100644 index 0000000000000000000000000000000000000000..c630ae1c466941e93781a4bf5ef33c874c375600 --- /dev/null +++ b/toMkdocs/gridTableFilter.py @@ -0,0 +1,36 @@ +# +# gridTableFilter.py +# +# (c) 2025 by Andreas Kraft & Miguel Angel Reina Ortega +# License: BSD 3-Clause License. See the LICENSE file for further details. +# +""" This script replaces the grid tables in the markdown files with the equivalent + html tables. Other markdown elements are not affected and are passed through. + + The script expects the markdown file to be converted from stdin and writes the + result to stdout. +""" + +import argparse, sys +from rich import print +from markdownTools import analyseMarkdown, setLoggers + +def main() -> None: + + # Parse the command line arguments + parser = argparse.ArgumentParser(description='Convert grid tables to html tables. This script reads the markdown file from stdin and writes the result to stdout.') + parser.add_argument('-v', '--verbose', action='store_true', help='Print debug information to stderr.') + args = parser.parse_args() + + # Set the loggers + setLoggers(info=lambda m: print(f'[green]{m}', file=sys.stderr) if args.verbose else None, + debug=lambda m: print(f'[dim]{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 + print(analyseMarkdown(inLines=sys.stdin.readlines()), file=sys.stdout) + + +if __name__ == '__main__': + main() +