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

Filter extensions can't be specified in combination with processing phases #11750

Open
multimeric opened this issue Dec 28, 2024 · 1 comment
Assignees
Labels
bug Something isn't working extensions relates to Quarto extensions mechanism lua Issues related to the lua codebase, filter chain, etc
Milestone

Comments

@multimeric
Copy link

Bug description

The AST processing phases feature doesn't seem compatible with packaged extensions.

This works:

filters:
  - path: lifecycle.lua
    at: pre-ast

Whereas this fails:

filters:
  - path: lifecycle
    at: pre-ast

With the error ERROR (/opt/quarto/share/filters/main.lua:3832) cannot open lifecycle: No such file or directory. I assume this is supposed to work, since otherwise extensions have no access to the lifecycle hooks.

Steps to reproduce

I've made a super simple reprex of this here: https://github.com/multimeric/quarto-lifecycle:

  1. git clone https://github.com/multimeric/quarto-lifecycle
  2. cd quarto-lifecycle
  3. quarto render example.qmd.

Expected behavior

The document to render without error.

Actual behavior

ERROR (/opt/quarto/share/filters/main.lua:3832) cannot open lifecycle: No such file or directory

Your environment

Ubuntu 22.04.

Quarto check output

Quarto 1.6.39
[✓] Checking environment information...
      Quarto cache location: /home/migwell/.cache/quarto
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.4.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.46.3: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.6.39
      Path: /opt/quarto/bin

[✓] Checking tools....................OK
      TinyTeX: v2024.12
      Chromium: (not installed)

[✓] Checking LaTeX....................OK
      Using: TinyTex
      Path: /home/migwell/.TinyTeX/bin/x86_64-linux
      Version: 2024

[✓] Checking basic markdown render....OK

[✓] Checking Python 3 installation....OK
      Version: 3.12.8 (Conda)
      Path: /home/migwell/micromamba/envs/bash-kernel/bin/python
      Jupyter: 5.7.2
      Kernels: python3, bash, rust

(|) Checking Jupyter engine render....Traceback (most recent call last):
  File "/opt/quarto/share/jupyter/jupyter.py", line 21, in <module>
    from notebook import notebook_execute, RestartKernel
  File "/opt/quarto/share/jupyter/notebook.py", line 15, in <module>
    from yaml import safe_load as parse_string
ModuleNotFoundError: No module named 'yaml'
[✓] Checking Jupyter engine render....OK
@multimeric multimeric added the bug Something isn't working label Dec 28, 2024
@mcanouil mcanouil added the extensions relates to Quarto extensions mechanism label Dec 28, 2024
@cscheid cscheid self-assigned this Jan 2, 2025
@cscheid cscheid added this to the v1.7 milestone Jan 2, 2025
@cderv
Copy link
Collaborator

cderv commented Jan 15, 2025

I wanted to check an idea, and I believe this happens because we are not resolving filter looking in extension.

Filters are resolved in

// resolve filters
const resolvedFilters = await resolveFilters(
[
...(allDefaults[kFilters] || []),
],
options,
allDefaults,
);

and resolved looking in extension
// Resolve any filters that are provided by an extension
filters = await resolveFilterExtension(options, filters);

but we only resolve filter of type string (so not { path: 'lifecycle', at: 'pre-ast'} at this part.
const getFilter = async (filter: QuartoFilter) => {
// Look for extension names in the filter list and result them
// into the filters provided by the extension
if (
filter !== kQuartoFilterMarker && filter !== kQuartoCiteProcMarker &&
typeof filter === "string"
) {

So the full filter path is not resolved, and on Lua side the filter can be loaded.

BTW @multimeric, with your example repo, this does not work for me either.

This works:

filters:
 - path: lifecycle.lua
   at: pre-ast

Extension or not it fails 🤔 same cause to me: we don't resolve filter of the form path / at in extensions as you found.

We should just tweak resolveFilters() to resolve filter path in extension also for entry point filter.

@cderv cderv added the lua Issues related to the lua codebase, filter chain, etc label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working extensions relates to Quarto extensions mechanism lua Issues related to the lua codebase, filter chain, etc
Projects
None yet
Development

No branches or pull requests

4 participants