-
Notifications
You must be signed in to change notification settings - Fork 13
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
Lua filters don't receive pandoc's AST, and don't output anything #38
Comments
panzer is not passing jsons to lua filters. The example you give works perfectly for me, so there must be some other issue. Try this simple example:
This produces the expected output in small caps. Note that This is actually consistent with pandoc's philosophy. Any filters should assume that stdin and stdout are 'taken' as pandoc is designed to operate on these channels -- consuming data from stdin and producing data to stdout. Diagnostics should go to some other output channel (stderr). |
If you want to pretty print, use the following expression in the filter to send a json message over stderr to panzer:
|
Lua filters are running normal. I've cleaned up my But there's a problem: in pandoc's lua filters, there's a function Pandoc (doc)
local jsonMessage = doc.meta['panzer_reserved']['json_message'][1].c[2]
io.stderr:write('{"level": "INFO", "message": "' .. jsonMessage .. '"}\n')
end And the beginning of
By now I can't continue with testing, but I'll test dkjson to deserialize that json and get the writer format. If there's a simpler method, please let me know. |
Thank you for this feedback. I've completely changed the implementation based on it as the
On the json message accessible to filters... Currently, the json message You are right therefore that to access this json message you need to:
It's pretty easy to do though and should just be ~2 lines of code. Hope that this helps! |
It's totally working: my lua filters are running really fast, and without any modifications from using directly with pandoc. Many many thanks, @msprev !!! |
Now I'm refining my workflow, and planning to create a repository with it including some panzer configuration along with my filters. Thanks! |
Wonderful! I’m really glad. Let me know if any issues crop up and it would be good to share workflows.
|
Starting with panzer 1.4, lua filters are supported (many thanks to @msprev !!). So I tried some lua filters that I wrote myself, and none of them got expected behaviour. In fact, it seems lua filters are receiving JSON, when should receive AST instead (according to pandoc's doc on lua filters).
For instance, I have this lua filter (very first example on lua filters in pandoc's doc). It should turn
Strong
elements intoSmallCaps
elements:Running directly with pandoc, it works. Using panzer, nothing happens. Below is my
styles.yaml
(excerpt), which only puts that lua filter to run:The filter is correctly found by panzer, and apparently runs, but no errors on lua-filter are shown when running panzer. Even
print('some debug')
doesn't output anything to console. I tried to use JSON on the lua filter, but I couldn't realize how to do that. My first try was like code below, withou any results:Am I missing something?
The text was updated successfully, but these errors were encountered: