-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Preprocessor in Python? #975
Comments
Preprocessors use a particular JSON api to exchange input and output. I believe the input is an array of |
This fails with |
A minimal preprocessor in Python would look like this: #!/usr/bin/env python
import json
import sys
if len(sys.argv) > 1:
if sys.argv[1] == 'supports':
# sys.argv[2] is the renderer name
sys.exit(0)
context, book = json.load(sys.stdin)
json.dump(book, sys.stdout) |
This was exactly what I was looking for. The docs does not really make it clear what the output should be. I've implemented a preprocessor in Python that sets up a tabbed interface for code or other content here. |
I was also confused by this - first that I only had to return the second array entry (which I now do see that the documentation states!) - but more importantly this thing about calling the script twice, which isn't specifically mentioned (only if you sit and think long and hard about the example code). Here is my renderer in PHP I finally got working:
|
I'm also getting this error with the code outlined in the documentation. book.toml has [preprocessor.xnos]
command = "python3 ./xnos.py --" Removing the |
I'm trying to figure out how to write a preprocessor in Python, given that it's listed in the example, but I can't even get started.
Results in
Clearly I'm missing something obvious.
The text was updated successfully, but these errors were encountered: