From: martin f. krafft Date: Sat, 20 Aug 2022 19:48:30 +0000 (+0200) Subject: enable reading from a file instead of stdin X-Git-Url: https://git.madduck.net/etc/mutt.git/commitdiff_plain/94698af38a3a5aa4d3dc3cbfe6aafb440dee8714?ds=inline enable reading from a file instead of stdin --- 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__':