From 94698af38a3a5aa4d3dc3cbfe6aafb440dee8714 Mon Sep 17 00:00:00 2001 From: "martin f. krafft" Date: Sat, 20 Aug 2022 21:48:30 +0200 Subject: [PATCH] enable reading from a file instead of stdin --- .config/mutt/markdown2html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.config/mutt/markdown2html b/.config/mutt/markdown2html index d5fa609..327dff2 100755 --- a/.config/mutt/markdown2html +++ b/.config/mutt/markdown2html @@ -328,10 +328,11 @@ def main(): Convert text on stdin to HTML, and print it to stdout, like mutt would expect. ''' - html = convert_markdown_to_html(sys.stdin.read()) - if html: - # mutt expects the content type in the first line, so: - print(f'text/html\n\n{html}') + with open(sys.argv[1], 'r') if len(sys.argv) > 1 else sys.stdin as f: + html = convert_markdown_to_html(f.read()) + if html: + # mutt expects the content type in the first line, so: + print(f'text/html\n\n{html}') if __name__ == '__main__': -- 2.39.2