marp-team / marp-team/marp-cli

Unpredictable output

Open
#490 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
194
Avg merge
2h 51m
Merged PRs (30d)
3

Description

Version of Marp Tool

v1.7.2

Operating System

Windows

Environment
  • OS version: ArchLinux and Alpine 3.16
  • Node.js version: marp core v2.4.2, nodejs v16.18.0
How to reproduce

By default, I expect the output file to go into the current/working directory and not in the input directory (at the same level as the input file). I understand that this is debatable and suggestive.

$ marp --theme-set themes  --input-dir docs                                                                                                                                                                                                                                                                                   
[  INFO ] Converting 1 markdown...                                                                                                                                                                                   
[  INFO ] docs/slides.md => docs/slides.html 

So if I want to be sure to control the output path I'll use the --output option which has this exact purpose.

$ marp --theme-set themes --output index.html --input-dir docs
[  INFO ] Converting 1 markdown...
[  INFO ] docs/slides.md => index.html/slides.html

The --output should be relative to the current/working directory so I expect the file index.html to go to $PWD/index.html. At list an expected bad behavior would be it still output to $PWD/docs/index.html. But here what the help message says:

$   -o, --output                       Output file path (or directory when                                                                                                                                             
                                     input-dir is passed)               [string]

So when input-dir is provided, --output is interpreted as a directory and not a file anymore, so it outputs to index.html/slides.html. Meaning I can control the output dir but not longer the file name.

$ marp --theme-set themes --output test --input-dir docs
[  INFO ] Converting 1 markdown...
[  INFO ] docs/slides.md => test/slides.html

$ marp --theme-set themes --output test/index.html --input-dir docs
[  INFO ] Converting 1 markdown...
[  INFO ] docs/slides.md => test/index.html/slides.html

Same context as in https://github.com/marp-team/marp/discussions/382

Expected behavior

eg curl has 2 options:

$ curl --help all | grep '\--output'
 -o, --output <file>      Write to file instead of stdout
     --output-dir <dir>   Directory to save files in

There should definitely be an --output-file and an --output-dir option with predictable behavior and not one --output option with unpredictable behavior that change relatively to other option being used.

Actual behavior

See How to reproduce

Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the documented commands using --input-dir and --output, then inspect the CLI's option parsing and output-path handling. Compare the current help text and behavior with the requested separate output-file and output-dir semantics. Done means the options have predictable, documented behavior for both single-file and input-directory conversions, with tests covering the examples.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.