From 007e77c507cd9bc8465caa46fc47abbd66d5c313 Mon Sep 17 00:00:00 2001 From: CBke Date: Sun, 20 Oct 2013 21:25:56 +0200 Subject: [PATCH] add option --title for filling in the title --- ansi2html/converter.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ansi2html/converter.py b/ansi2html/converter.py index 36d9cb2..04cf89c 100755 --- a/ansi2html/converter.py +++ b/ansi2html/converter.py @@ -66,7 +66,7 @@ - +%(title)s @@ -189,7 +189,8 @@ def __init__(self, escaped=True, markup_lines=False, output_encoding='utf-8', - scheme='ansi2html' + scheme='ansi2html', + title='' ): self.inline = inline @@ -200,6 +201,7 @@ def __init__(self, self.markup_lines = markup_lines self.output_encoding = output_encoding self.scheme = scheme + self.title = title self._attrs = None if inline: @@ -369,6 +371,7 @@ def convert(self, ansi, full=True, ensure_trailing_newline=False): else: return _template % { 'style' : "\n".join(map(str, get_styles(self.dark_bg, self.scheme))), + 'title' : self.title, 'font_size' : self.font_size, 'content' : attrs["body"], 'output_encoding' : self.output_encoding, @@ -437,6 +440,10 @@ def main(): default='ansi2html', choices=scheme_names, help=("Specify color palette scheme. Default: %%default. Choices: %s" % scheme_names)) + parser.add_option( + '-t', '--title', dest='output_title', + default='', + help="Specify output title") opts, args = parser.parse_args() @@ -449,6 +456,7 @@ def main(): markup_lines=opts.markup_lines, output_encoding=opts.output_encoding, scheme=opts.scheme, + title=opts.output_title, ) def _read(input_bytes):