-
Notifications
You must be signed in to change notification settings - Fork 331
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
Quarto does not allow to add filters after citeproc processing, leading to uncorrect results #9726
Comments
I don't believe this is a bug - filters have to be specified per document, as in the example here: https://quarto.org/docs/extensions/filters.html#filter-extensions |
Do you mean that the filter should be specified in |
Can you provide an example of one that works as you expected? |
I have added the Lua filter abstract-section in the repo, and it works as expected. |
Ok. First, a correction on my side. The filter is getting called in the pipeline, and I didn't realize this actually worked. This is generally speaking a bad idea; multiple filters usually require coordination and specifying them in different places (say, But, in any case, try this replacement on your own code: function Pandoc(doc)
print(pandoc.write(doc, "native"))
end
return {
{
Pandoc = Pandoc,
Cite = process_cite,
Link = process_cite,
Div = Div
}
} and you'll see the printout:
That means your filter is executing. It's just something in the document that is not working as your code expects. |
Thanks for your diagnosis. But I cannot figure out why the Lua filter is executed from the native output. Further, the html output was not modified by the Lua filter as expected. Could you please help to diagnose why the Lua filter can work on the command line but not by adding in |
This is the diff of the command Pandoc
Meta
{ unMeta =
fromList
[ ( "bibliography"
, MetaList [ MetaInlines [ Str "bib.bib" ] ]
)
, ( "csl" , MetaInlines [ Str "gb-author-date.csl" ] )
, ( "title"
, MetaInlines
[ Str "Lua"
, Space
, Str "Filter"
, Space
, Str "Test"
]
)
]
}
[ Para
[ Str "Testing"
, Space
, Str "citations"
, Space
, Cite
[ Citation
{ citationId = "knuth84"
, citationPrefix = []
, citationSuffix = []
, citationMode = AuthorInText
, citationNoteNum = 1
, citationHash = 0
}
]
[ Str "Knuth" , Space , Str "(1984)" ]
, Space
, Str "and"
, Space
, Cite
[ Citation
{ citationId = "han2020"
, citationPrefix = []
, citationSuffix = []
, citationMode = AuthorInText
, citationNoteNum = 2
, citationHash = 0
}
]
- [ Str "\38889\26093\19996\160et"
- , Space
- , Str "al."
+ [ Str "\38889\26093\19996\160\31561"
, Space
, Str "(2020)"
]
, Space
, Str "for"
, Space
, Str "using"
, Space
, Str "the"
, Space
, Str "Lua"
, Space
, Str "filter."
]
, Div
( "refs"
, [ "references" , "csl-bib-body" , "hanging-indent" ]
, [ ( "entry-spacing" , "0" ) ]
)
[ Div
( "ref-knuth84" , [ "csl-entry" ] , [] )
[ Para
[ Str "Knuth"
, Space
, Str "D"
, Space
, Str "E,"
, Space
, Str "1984."
, Space
, Str "Literate"
, Space
, Str "Programming[J/OL]."
, Space
, Str "Comput."
, Space
, Str "J.,"
, Space
, Str "27(2):"
, Space
, Str "97\8211\&111."
, Space
, Link
( "" , [] , [] )
[ Str "https://doi.org/10.1093/comjnl/27.2.97" ]
( "https://doi.org/10.1093/comjnl/27.2.97" , "" )
, Str "."
, Space
, Str "DOI:"
, Space
, Link
( "" , [] , [] )
[ Str "10.1093/comjnl/27.2.97" ]
( "https://doi.org/10.1093/comjnl/27.2.97" , "" )
, Str "."
]
]
, Div
( "ref-han2020" , [ "csl-entry" ] , [] )
[ Para
[ Str "\38889\26093\19996,"
, Space
, Str "\26446\24503\38451,"
, Space
, Str "\29579\33509\30007,"
, Space
- , Str "et"
- , Space
- , Str "al.,"
+ , Str "\31561,"
, Space
, Str "2020."
, Space
, Str
"\30408\20313\20998\37197\21046\24230\23545\21512\20316\31038\32463\33829\32489\25928\24433\21709\30340\23454\35777\20998\26512\65306\22522\20110\26032\21046\24230\32463\27982\23398\35270\35282[J]."
, Space
, Str "\20013\22269\20892\26449\32463\27982(4):"
, Space
, Str "56\8211\&77."
]
]
]
] From the native output, I don't think the Lua filter was applied, or applied correctly at least. |
That isn't consistent with the testing I've done. If you add |
Could you please help to see what's the problem with the Lua filter, and how can I fix it? Thanks very much! |
@TomBener here are some resources to help you debug this on your end.
Hope this helps |
@cderv Many thanks for your guidance. But I'm confused with the "More precise targeting of AST processing phases" in the document. I cannot fully understand the implications of the three parts: |
We have no more documentation yet on this. Those are only possible steps where you can apply your filter. By default, the filter will apply at the end IIRC.
Read the doc about Extensions and How Lua filters works. You can do anything from the Parsed Markdown by Pandoc until the writing to output format. So you can do a Lua filter that would catch some object and output Raw LaTeX. but Lua filters cannot be used to post process LaTeX files that would have been generated by Pandoc conversion. Quarto will call LaTeX on it directly. Hope it helps understand. I did not know how advanced you may be so I mentioned the three parts. You should not consider this for now, and only try to debug your filter using logging at different places in your processing. |
@cderv Thanks! |
I'm going to go ahead and close this one, since I don't think there's anything outstanding. |
Sorry I don't think so. Some Lua filters not applying is indeed a problem I have not resolved. I have updated to test Citation Backlinks Filter by @tarleb, but it didn't work in my Quarto example. |
@TomBener as discussed this is specific ordering of how the lua filters should be applied. I gave some hints to look into this, and try debug so that you could come back and provide more details on what is not working.
Let's just deal with that first: The README of this filter clearly state:
So you can't expect it to work ! There is even an issue in there about this: tarleb/citation-backlinks#2 The reason this filter is not working is probably the same as yours, if So more generally, Lua filters that requires to be ran after citeproc does not work yet in Quarto extension. This is discussed at with another filter not working and we are tracking the improvement at Currently, we call citeproc as part of the default files after all the other filters, and there is no way to apply it after. Using I hope this helps understand. I'll rename this issue to make clear what this is about. And follow #7888 for resolution of this limitation. |
Duplicate of #7888 |
@cderv Thanks very much! I think your comment is correct and it helps me understand the cause for the issue. All my Lua filters that cannot be used as Quarto extensions are indeed related to citeproc. |
Bug description
Hello Quarto team,
I am experiencing an issue where a specific Lua filter is not being applied when rendering a document in Quarto.
When I run the command
quarto render --to html
, the Lua filter specified in my_quarto.yml
file is not applied. In the HTML output, it generated the reference as:However, when I manually specify the Lua filter in the command line with
quarto render --to html -L _extensions/filters/localize-cnbib/localize-cnbib.lua
, it works as expected (et al.
was replaced with等
):Reproduction Steps
To demonstrate the problem, I have created a GitHub repo to reproduce the issue.
Environment
Here is the output of
quarto check
:The text was updated successfully, but these errors were encountered: