tomduck / pandoc-xnos

Library code for pandoc-fignos/eqnos/tablenos/secnos.
GNU General Public License v3.0
106 stars 27 forks source link

Feature: allow passing path to pandoc in init() #8

Closed jspayne closed 4 years ago

jspayne commented 6 years ago

I'd like to be able to pass the path to pandoc to init and have init figure out the pandoc version:

pversion = pandocxnos.init(local_path='../my/local/dir/pandoc')

This would allow me to reference a portable version of pandoc without putting it in the path.

tomduck commented 6 years ago

Thanks for your comment. The intent of the init() function is to allow pandoc filters to initialize the pandoc-xnos library. Usually there is already a pandoc process running, and the init() function (since pandoc 1.19.1) simply retrieves and returns the PANDOC_VERSION environment variable. For earlier pandoc versions it is more difficult, as you can see from the init() code.

It seems to me that you want to do something different: retrieve the version number of a particular pandoc instance. It is probably easiest for you to just use this bit of code from the init() function:

    output = subprocess.check_output([command, '-v'])
    line = output.decode('utf-8').split('\n')[0]
    pandocversion = line.split(' ')[-1].strip()

Set command = '../my/local/dir/pandoc' first. Notice that this requires the subprocess module.

Please let me know if I am misunderstanding your concern.

Cheers, Tom

tomduck commented 4 years ago

Hi there. I'm closing this Issue given that it is likely no longer of interest. If that is not the case, please feel welcome to re-open it. Cheers, Tom.