From abf2e9ab1d018974702ebbe0932912fd20d3e123 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Fri, 22 Jun 2012 23:02:56 +0200 Subject: [PATCH] Read stdin when no file is specified --- scripts/misaka | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/misaka b/scripts/misaka index 18f1382..1386e10 100755 --- a/scripts/misaka +++ b/scripts/misaka @@ -77,11 +77,14 @@ if __name__ == '__main__': renderer = HtmlRenderer(flags) to_html = Markdown(renderer, extensions).render - for fn in files: - fn = path.abspath(fn) - if not path.exists(fn): - print('Does not exist: %s' % fn) - else: - with open(fn, 'r') as fd: - source = fd.read() - print(to_html(source)) + if files: + for fn in files: + fn = path.abspath(fn) + if not path.exists(fn): + print('Does not exist: %s' % fn) + else: + with open(fn, 'r') as fd: + source = fd.read() + print(to_html(source)) + else: + print(to_html(sys.stdin.read()))