From 021ba9fafc41021c75719303fb36d030b632b5f4 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Mon, 4 Sep 2023 13:05:39 -0700 Subject: [PATCH] Add htmlescape.py. --- htmlescape.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 htmlescape.py diff --git a/htmlescape.py b/htmlescape.py new file mode 100644 index 0000000..27c373a --- /dev/null +++ b/htmlescape.py @@ -0,0 +1,32 @@ +import html +import argparse +import sys + +from voussoirkit import betterhelp +from voussoirkit import vlogging +from voussoirkit import pipeable + +log = vlogging.getLogger(__name__, 'htmlescape') + +def htmlescape_argparse(args): + text = pipeable.input(args.text, split_lines=False) + pipeable.stdout(html.escape(text)) + return 0 + +@vlogging.main_decorator +def main(argv): + parser = argparse.ArgumentParser( + description=''' + ''', + ) + parser.add_argument( + 'text', + help=''' + ''', + ) + parser.set_defaults(func=htmlescape_argparse) + + return betterhelp.go(parser, argv) + +if __name__ == '__main__': + raise SystemExit(main(sys.argv[1:]))