pandoc icon indicating copy to clipboard operation
pandoc copied to clipboard

[feature] more shell completions

Open Freed-Wu opened this issue 3 years ago • 8 comments

Describe your proposed improvement and the problem it solves.

Now pandoc --bash-completion can generate bash completion script. Why not provide more --XXsh-completion? For example, zsh has a completion script for pandoc, however, it is written manually:

_arguments -s \
  {-f+,-r+,--from=,--read=}'[specify input format]: :_pandoc_format -T input' \
  {-t+,-w+,--to=,--write=}'[specify output format]: :_pandoc_format -T output' \
  {-o+,--output=}'[write output to FILE instead of stdout]:file:_files' \
  '--data-dir=[specify the user data directory to search for pandoc data files]:data directory:_files -/' \
  {-d+,--defaults=}'[read default from YAML file]: :_pandoc_defaults_file' \
  '--shift-heading-level-by=[shift heading levels by specified number]:positive or negative integer: ' \
  '!--base-header-level=:number [1]:(1 2 3 4 5)' \
  '!--strip-empty-paragraphs[deprecated. Use the +empty_paragraphs extension instead]' \
  '--indented-code-classes=[classes to use for indented code blocks]:class list (comma-separated)' \
  '--default-image-extension=[specify a default extension to use when image paths/URLs have no extension]:extension: ' \
  '--file-scope[parse each file individually before combining for multifile documents]' \
  ...

When the option of pandoc changed, the maintainers of zsh have to update it manually. If pandoc can provide --zsh-completion which use this file as a template but update automatically, it will be greater.

TIA!

Freed-Wu avatar Jan 11 '23 15:01 Freed-Wu

Related: #4668.

tarleb avatar Jan 11 '23 22:01 tarleb

As noted in the linked issue: I don't want to integrate a completion script that is mostly manually written. If it can be done in a template form like the bash completions, we could consider it.

jgm avatar Jan 11 '23 22:01 jgm

If it can be done in a template form like the bash completions, we could consider it.

zsh support completing the descriptions of options, that is:

For zsh:

❯ pandoc --<TAB>
option
--abbreviations              specifies a custom abbreviations file
--ascii                      use only ASCII characters in output, supported only for HTML and DocBook output
--bash-completion            generate a bash completion script
--biblatex                   use biblatex for citations in LaTeX output
...

For bash which don't support descriptions of options.

$ pandoc --<TAB>
--ascii
--atx-headers
--base-header-level
--bash-completion
--biblatex
...

However, the descriptions of options exists in the man page, which is generated from a markdown file MANUAL.txt by pandoc.

However pandoc --zsh-completion cannot access MANUAL.txt. I think use a script to handle MANUAL.txt to generate zsh completion script _pandoc is a little weird. Otherwise users have to give up the descriptions of options.

Freed-Wu avatar Jan 13 '23 13:01 Freed-Wu

Moreover, zsh wants concise half-line descriptions, and MANUAL.txt won't provide those.

jgm avatar Jan 13 '23 16:01 jgm

zsh wants concise half-line descriptions, and MANUAL.txt won't provide those.

Right. It looks like before this problem is fixed, the support for zsh compleiton is hard to realize.

Freed-Wu avatar Apr 04 '23 07:04 Freed-Wu

With pandoc 3.1.11.1 on Debian, still:

$ cat --<TAB>
--help  --show-tabs  --version ...
$ pandoc --<TAB>

Nothing.

jidanni avatar Nov 28 '25 23:11 jidanni

@jidanni Isn't that a Debian packaging issue rather than anything specific to this project? We do provide a way to get shell completions, but the system has to be set up to integrate them....

jgm avatar Nov 29 '25 16:11 jgm

OK, I filed https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1121654

jidanni avatar Nov 30 '25 01:11 jidanni