Skip to content

Commit 117da11

Browse files
committed
Allow multiple file inputs for the converter
1 parent 935665d commit 117da11

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

mint2html.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2026, Julian Müller (ChaoticByte)
44
# Licensed under the BSD 3-Clause License
55

6-
# pylint: disable=line-too-long,missing-module-docstring,missing-class-docstring,missing-function-docstring
6+
# pylint: disable=line-too-long,missing-module-docstring,missing-class-docstring,missing-function-docstring,invalid-name
77

88
from html import escape
99
from pathlib import Path
@@ -175,7 +175,7 @@ def process_inline_tag(c1: str, state: ConverterState, t: MintTagToHtml):
175175
from argparse import ArgumentParser
176176

177177
argp = ArgumentParser()
178-
argp.add_argument("-i", "--input-file", help="Input file (will read from stdin until eof when omitted)", type=Path, required=False)
178+
argp.add_argument("-i", "--input-file", help="Input file(s) (will read from stdin until eof when omitted)", type=Path, required=False, nargs="*")
179179
argp.add_argument("-o", "--output-file", help="Output file (will print to stdout when omitted)", type=Path, required=False)
180180
argp.add_argument("--css", help="Add css to the html output", type=str, default="")
181181
argp.add_argument("--no-escape-html", help="Don't escape html in the input", action="store_true")
@@ -191,11 +191,14 @@ def process_inline_tag(c1: str, state: ConverterState, t: MintTagToHtml):
191191
input_lines = []
192192
for l in stdin:
193193
input_lines.append(l)
194-
input_text = "\n".join(input_lines) # pylint: disable=invalid-name
194+
input_text = "\n".join(input_lines)
195195
del input_lines
196196
else:
197-
log(f"Reading text from {str(args.input_file)} ...")
198-
input_text = args.input_file.read_text()
197+
log(f"Reading text from {str([str(f) for f in args.input_file])} ...")
198+
inputs = []
199+
for f in args.input_file:
200+
inputs.append(f.read_text())
201+
input_text = "\n".join(inputs)
199202

200203
log("Converting text ...")
201204
output_document = MintToHtmlConverter(
@@ -206,7 +209,7 @@ def process_inline_tag(c1: str, state: ConverterState, t: MintTagToHtml):
206209
if args.minify_html:
207210
log("Minifying html output ...")
208211
import minify_html
209-
output_document = minify_html.minify(output_document)
212+
output_document = minify_html.minify(output_document) # pylint: disable=no-member
210213

211214
if args.output_file is None:
212215
log("Writing output to stdout ...")

0 commit comments

Comments
 (0)