vim-pandoc / vim-pandoc-legacy

[UNSUPPORTED/use vim-pandoc/vim-pandoc] vim bundle for pandoc users
143 stars 23 forks source link

Allow pipelines in executors (+ other improvements) #30

Closed fmoralesc closed 13 years ago

fmoralesc commented 13 years ago

The current implementation of pandoc_execute is a bit inflexible, and doesn't allow for command descriptions like:

pandoc -t json % | runhaskell FILTER | pandoc -f native -t latex --bibliography g:pandoc_bibfiles 

which should be executed as

pandoc -t json CURRENT_FILE | runhaskell FILTER | pandoc -f native -t latex [--bibliography bibfile]* -o CURRENT_FILE.latex

We need to specify a set of variables to escape. Right now, we escape buffer and global variables, but we also might want to escape % (like in the above example).

The output type should be inferred from the last command in the pipe, or be defined in PandocRegisterExecutor's call (should be more flexible), as we did originally.

fmoralesc commented 13 years ago

This will require some API changes to PandocRegisterExecutor:

  1. We'll have to register the output type. Guessing the output type is madness in the long run.
  2. We have to give all the arguments to the command explicitly.
  3. We have to limit the possible variable substitutions.

I have implemented this in a local branch, without regressions (default executors work fine), but I'm undecided on whether to merge it into master because of the API change. I'm not too keen on messing with other people's configurations (or maybe none is using custom executors?).

With the changes I have, instead of registering an executor like this,

PandocRegisterExecutor PandocOdt <localleader>odt pandoc -t odt --bibliography b:pandoc_bibfiles

we have to call it like this:

PandocRegisterExecutor PandocOdt <localleader>odt odt pandoc -t odt PANDOC#BIBS -o %:r.odt %%

The variable substitutions allowed for now are few, and are all in display in the example above:

  1. %% for the current filename
  2. %:r for the current filename without the extension
  3. PANDOC#BIBS for a sequence of --bibliography arguments for every value in b:pandoc_bibfiles (might be good to have something else for just the sequence of values in b:pandoc_bibfiles).
fmoralesc commented 13 years ago

I've pushed the changes to master. There should be no regressions, and the changes in the API are documented.