-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Include pandoc version in json abstract syntax tree #2640
Comments
I think that something like this is needed. I'm not sure adding it to the metadata is the right thing to Maybe it should be a separate field in the JSON? Another issue is that pandoc and pandoc-types have separate |
OK, great. As long as the info is somewhere in the JSON, then filter authors will be able to get at it. For my use case, it is the pandoc version that is important. Perhaps both the pandoc and pandoc-types versions could be included. |
For one possible approach see though I've had second thoughts and reverted it for now. Mainly the second thoughts are because this only gives you the pandoc-types version, not also pandoc. But I don't see how we can give pandoc version, since toJSONFilter is entirely defined in pandoc-types. |
That field would provide a version of the A stringly typed variant would be to have libraries/programs insert their version into the A slightly more controlled variant is to add an abstract "tool-versions":
{
"pandoc": [1, 17],
"pandoc-types": [1, 17, 1],
"pandoc-citeproc": [0,10]
} Of course this requires a change to the Pandoc type which affects all readers, writers and filters. With a few helper functions the |
Is there a way to minimize the impact? e.g., Add “tools-versions" as a new field to the same JSON dict as “unMeta”? Perhaps append a new item to the JSON structure? In either case I know that my filters would continue to work without modification. I suspect that this would be the case for (many? all?) other python filters. I don’t know enough about the expectations of Haskell to assess the rest. |
Passing all these versions as strings every time we What if we added an option to pandoc to spit out all pandoc --library-versions +++ Thomas J. Duck [Jan 12 16 06:37 ]:
|
True, although compared to the amount of data serialized to JSON it seems rather small.
I can’t count on accessing the correct version of pandoc using a shell call. It is possible that people will have multiple pandoc versions installed on their machine (I do). It would also mean the filter would not work with any renamed pandoc forks. I think version information needs to somehow be passed along by pandoc to its filters. |
Any further thoughts on this request? I'm concerned that if pull request #2637 gets accepted that my filters won't be able to reliably detect the changed LaTeX/pdf writer. Having pandoc pass along version information in its JSON would allow for more robust filters. Cheers. :o) |
I still don't know how to deal with this. Currently the JSON is generated by a module in pandoc-types, Pandoc could add something to the metadata before calling Perhaps implementing a convention for writers to ignore +++ Thomas J. Duck [Jan 24 16 14:34 ]:
|
I see the new "pandoc-api-version" in the JSON output and have adapted the pandoc-fignos filter (and friends) accordingly. Thank you! It would still be useful to have the pandoc version in the JSON in order to accommodate changes in pandoc's writers (which I assume won't be reflected in "pandoc-api-version"). So I will leave this issue open if that is OK. Cheers. |
I'd rather set an environment variable, PANDOC_VERSION. That would work too, right? |
@jgm: Yes, that should work. |
This works great. Thanks, @jgm. |
* Pandoc JSON is now a three-element array, whose first element gives the version of pandoc types. It has the form of an array of numbers, e.g. [1,16,1]. * fromJSON will now raise an error unless the type encoded in the JSON is compatible with the version of pandoc-citeproc the program was compiled against. ("Compatible with" means that the first three digits of the version number must match.) * This change means that if pandoc is compiled against pandoc-types 1.16.1, any filters it uses must also be. Addresses #2640.
Given the evolving pandoc API, it would be very helpful for filter writers if the pandoc version number could be included in the json abstract syntax tree. For example, it could be stored in the unMeta field along with the other metadata. Filter writers could then retrieve the pandoc version and adjust the behavior of their filters accordingly.
Note that a simple call like "pandoc -v" from the filter won't work if users have multiple versions of pandoc installed (as I do, for testing purposes).
As an example of how not being able to detect the pandoc version causes a problem, please see this comment on pull request #2637 which has just been submitted. The changing behavior of the LaTeX writer will likely cause a conflict with my pandoc-fignos filter. If I could detect the pandoc version, then I would be able to make adjustments allowing the filter to operate in a backward-compatible manner.
The text was updated successfully, but these errors were encountered: