jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.62k stars 3.38k forks source link

Format & extension command-line handling #7797

Closed not-my-profile closed 2 years ago

not-my-profile commented 2 years ago

The CLI around formats and extensions behaves in some unexpected ways.

Passing an unknown format or extension to -f or -t should make the command fail immediately instead of reading from stdin first (only to inevitably fail):

$ pandoc -f unknown_format
why do you let me write here?
^D
Unknown input format unknown_format
$ pandoc -t unknown_format
why do you let me write here?
^D
Unknown output format unknown_format

Running --list-extensions with a format that does not exist should return an error:

$ pandoc --list-extensions=unknown_format
-east_asian_line_breaks

Specifying an extension that doesn't exist for a format that doesn't exist should probably report an unknown format error (but currently reports an unknown extension error):

$ echo | pandoc -f a+b                             
Error parsing reader format "a+b": (line 1, column 4):
unexpected end of input
Unknown extension: b
$ echo | pandoc -t a+b
Error parsing writer format "a+b": (line 1, column 4):
unexpected end of input
Unknown extension: b

Pandoc version? pandoc 2.16.2 on Linux

jgm commented 2 years ago

I fixed the first issue. I think the other behaviors are not really problematic.

not-my-profile commented 2 years ago

Thanks! I agree that the third behavior is unlikely to cause much problems. The second one however might lead to confusion when users misspell a format, e.g:

$ pandoc --list-extensions=comonmark
-east_asian_line_breaks

for such mishaps an error message would be more userfriendly.

jgm commented 2 years ago

OK, can do that.