Skip to content
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

improve pre-post filter decomposition #4113

Closed
cscheid opened this issue Jan 26, 2023 · 8 comments
Closed

improve pre-post filter decomposition #4113

cscheid opened this issue Jan 26, 2023 · 8 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@cscheid
Copy link
Collaborator

cscheid commented Jan 26, 2023

cc @dragonstyle

We want to do filters like this:

      filters:
        pre:
          - pre.lua
        render:
          - render.lua
        post:
          - post.lua

The inspiration is the sweet positioning of asciidoc.lua and that's how everything else should be in our filter chain.

@cscheid cscheid added the enhancement New feature or request label Jan 26, 2023
@cscheid cscheid added this to the v1.4 milestone Jan 26, 2023
@cscheid cscheid self-assigned this Jan 26, 2023
@cderv
Copy link
Collaborator

cderv commented Jan 27, 2023

This would definitely help fill the gap with some R Markdown feature for custom formats. With R Markdown, one can define some pre / post hooks in output_format() and obviously do stuff during rendering:

  • Before knitting
  • (During knitting by using knitr hooks)
  • After knitting
  • Before render with Pandoc
  • (During pandoc render by passing filters to Pandoc)
  • After render after render with Pandoc.

Everything is in R for those hooks. Obviously for Quarto it will be Lua. Some pre and post filter will definitely help !

So 👍 to this !

@cscheid cscheid modified the milestones: v1.4, v1.3 Jan 27, 2023
@cscheid
Copy link
Collaborator Author

cscheid commented Jan 27, 2023

This unblocks @allenmanning's switch to a simpler, more robust confluence render. So it's going to 1.3.

After discussing with Al, we're ok with doing this on 1.4.

@cscheid cscheid added the needs-discussion Issues that require a team-wide discussion before proceeding further label Feb 28, 2023
@cscheid cscheid modified the milestones: v1.3, v1.4 Mar 7, 2023
@cscheid cscheid removed the needs-discussion Issues that require a team-wide discussion before proceeding further label Mar 7, 2023
@cscheid
Copy link
Collaborator Author

cscheid commented Mar 13, 2023

See also #2294. Let's consider how to allow after-citeproc filters as well (and where exactly to take citeproc processing since we can call it with pandoc.utils.citeproc)

@andrewheiss
Copy link

andrewheiss commented Apr 5, 2023

Here's a quick example of where a post-rendering Lua filter would be helpful: https://github.com/andrewheiss/quarto-wordcount#how-this-all-works. The filter works now because of the citeproc.lua wrapper mentioned in #2294 (in this comment), but someday it'll be neat to just do something like this:

format:
  html:
    filter:
      post:
        - '/path/to/wordcount.lua'

@cscheid
Copy link
Collaborator Author

cscheid commented Apr 5, 2023

@andrewheiss Just to be clear, we already have "post" filters, they're not just "post enough" for handling the output of citeproc!

With that said, your use case is more than sufficient to convince me. (The quarto-wordcount filter is sweet!)

@andrewheiss
Copy link

Ha, html: filter: super-duper-post: then :)

@andrewheiss
Copy link

Related to this again, it would be helpful to have control over the filter ordering here in order to do things like extract the #appendix section for counting words. Right now in quarto-wordcount, if I want to count the words in the appendix separately, I have to put all the appendix sections in their own custom div (see https://github.com/andrewheiss/quarto-wordcount#appendices and andrewheiss/quarto-wordcount#2 (comment)). The Lua script seems to run before Quarto moves all the {.appendix} sections down to the end.

@cscheid
Copy link
Collaborator Author

cscheid commented Dec 4, 2023

This is now available on main. Full documentation incoming, but a brief description is available on the pre-release notes.

@cscheid cscheid closed this as completed Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants