diff --git a/bin/main.js b/bin/main.js index 2db87950..2174f139 100644 --- a/bin/main.js +++ b/bin/main.js @@ -98,6 +98,10 @@ export async function main(nodeProcess) { } while (argv.length) { + if (argv[0] === '--') { + files.push(...argv.slice(1)); + break; + } arg = getArg(); switch (arg) { case '-o': diff --git a/man/marked.1.md b/man/marked.1.md index a4b360d8..b47ad196 100644 --- a/man/marked.1.md +++ b/man/marked.1.md @@ -29,6 +29,9 @@ marked --output="hello world.html" -i in.md --no-breaks ## OPTIONS +* -- +End option parsing. Arguments after this are treated as input filenames, even if they start with a hyphen. + * -o, --output [output file] Specify file output. If none is specified, write to stdout. diff --git a/test/unit/bin.test.js b/test/unit/bin.test.js index befaefc7..e5e325db 100644 --- a/test/unit/bin.test.js +++ b/test/unit/bin.test.js @@ -304,6 +304,29 @@ describe('bin/marked', () => { }); describe('input', () => { + it('does not treat --=value as the end of options', testInput({ + args: ['--=ignored', '--string', '# test'], + stdout: '
~~file contents~~
\n\n'); + assert.strictEqual(stderr, ''); + } finally { + await rm(dir, { recursive: true, force: true }); + } + }); + } + it('input file positional', testInput({ args: [fixturePath('bin-input.md')], stdout: '