Lua filters run in the project directory, but `quarto.project.offset` is relative to the page's directory
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by tracing how q2 runs page Lua filters and sets quarto.project.offset; the issue gives a reproduction in where.lua and the relevant history in #1209. Compare the reproduced working directories and offset values with Quarto 1.9.37, then determine which expected behavior the project should adopt. Done means the subdirectory page can open the project file through its filter and the chosen behavior is documented if it changes Quarto 1 compatibility.
索引モデルが issue の本文から書いたものです。
説明
This issue was written by Claude while adding q2 support to Great Docs. The output shown comes from running each repro.
Bug description
In a website, q2 runs every page's Lua filters with the project root as the working directory.
Quarto 1 runs them in the page's own directory. quarto.project.offset still follows the Quarto 1
convention: it's the path from the page's directory to the project root, .. for sub/page.qmd.
So a filter that opens quarto.project.offset .. "/some-file" finds the file only for pages at the
root of the project. For a page in a subdirectory, the path points above the project. A filter that
opens a path relative to the page fails the same way.
Great Docs' interlinks filter loaded its cross-reference index from
quarto.project.offset .. "/_inv/index.lua". Under q2, no page in reference/ or user-guide/
found the index, so none of their references became links. The filter now tries
quarto.project.directory first, which works under both. Third-party extensions that reach project
files through the offset will hit the same problem.
Since #1209 (which closed #1202), a page's code cells run in the page's directory, as in Quarto 1.
Its filters still run in the project directory. So a page's code and its filters now resolve the
same relative path differently.
Related: #939 (added quarto.project).
Steps to reproduce
mkdir -p filter-cwd/sub && cd filter-cwd
printf 'project:\n type: website\nfilters:\n - where.lua\n' > _quarto.yml
printf -- '---\ntitle: Home\n---\n\nHome.\n' > index.qmd
printf -- '---\ntitle: Page\n---\n\nPage.\n' > sub/page.qmd
printf 'hello\n' > data.txt
cat > where.lua <<'LUA'
function Pandoc(doc)
local path = quarto.project.offset .. "/data.txt"
local f = io.open(path, "r")
quarto.log.output("cwd: " .. pandoc.system.get_working_directory())
quarto.log.output("offset: " .. quarto.project.offset .. ", opened " .. path .. ": " .. tostring(f ~= nil))
if f then f:close() end
end
LUA
q2 render
Actual behavior
cwd: /private/tmp/filter-cwd
offset: ., opened ./data.txt: true
cwd: /private/tmp/filter-cwd
offset: .., opened ../data.txt: false
Rendered 2 of 2 files to /private/tmp/filter-cwd/_site
The second pair of lines is sub/page.qmd. It runs in the project directory, so ../data.txt is
outside the project.
Expected behavior
As in Quarto 1.9.37:
cwd: /private/tmp/filter-cwd
offset: ., opened ./data.txt: true
cwd: /private/tmp/filter-cwd/sub
offset: .., opened ../data.txt: true
Either of these would fix it:
- Run a page's filters in the page's directory, as Quarto 1 does and as #1209 now does for code
cells. - Or keep the project directory, make
quarto.project.offsetrelative to it (.), and list the
change in the Quarto 1 differences docs.
The first keeps existing extensions working, including ones that open paths relative to the page.
- 主要言語
- Rust
- スター
- 316
- フォーク
- 23
- 平均マージ
- 6時間 50分
- マージ済み PR(30日)
- 230
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
quarto-dev/q2 のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
quarto-dev/q2#1188 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
quarto-dev/q2#1179 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
quarto-dev/q2#1133 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
quarto-dev/q2#1103 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
quarto-dev/q2#1095 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
limitlessprojects/Go-Hybrid#4764 ·
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue ready
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
MartinPTielemans/ilo#4238 ·
メンテナーはふだん 1 日以内に返信
-
area:compat area:operations documentation ready-for-agent type:afk
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
ZcashFoundation/zinder#552 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信