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

Added stdin/stdout filter to convert grid tables to html

parent ea4853f4
No related branches found
No related tags found
1 merge request!1Restructuring and cleaning scripts for Mkdocs
#
# 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()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment