[go: up one dir, main page]

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

Local files aren't moved with website building. #7

Open
BradyAJohnston opened this issue Aug 16, 2022 · 8 comments
Open

Local files aren't moved with website building. #7

BradyAJohnston opened this issue Aug 16, 2022 · 8 comments

Comments

@BradyAJohnston
Copy link
Contributor
BradyAJohnston commented Aug 16, 2022

An issue I was running into while trying to get the snapshots working in #6 , was that when trialling it on a quarto blog, while the molstar.molj file was in the correct location with the original index.qmd document, upon actual rendering of the website with quarto render or quarto preview everything was copied to the docs folder, but the molstar.molj was left behind and thus broke the URL.

Is there a way to mark specific files inside of the Lua / Pandoc to be treated as assets by Quarto? I assume that would fix the problem. Similar to what is done with images and other assets already inside of Quarto.

@kjelljorner
Copy link
Contributor

I think the resources option under the project key would be one way to do this: https://quarto.org/docs/reference/projects/core.html

@BradyAJohnston
Copy link
Contributor Author

Ah yes that fixes it! Having

resources: molstar.molj

in the header YAML fixes it. Can be on a single document basis as well.

I think we'll need to put this into the docs as well, as currently local .pdb or .xtc files break as well for blog posts.

@jmbuhr
Copy link
Owner
jmbuhr commented Aug 17, 2022

Ideally, we would do this automatically in the shortcode. Shortcodes do get the yaml metadata e.g.

local molstarMeta = pandoc.utils.stringify(meta['molstar'])

but I think they can't modify it.

Regular filters on the other hand could operate on the metadata, but this would require additional parsing for the shortcodes and their content, which feels a bit convoluted and I am not sure about the order of resource discovery and filters.
I will ask the quarto devs if they have a more elegant solution.

@jmbuhr
Copy link
Owner
jmbuhr commented Aug 17, 2022

When we add automatic addition of resources it will only work for those explicitly mentioned in the shortcode. For snapshots such as molstar.molj we will have to ask the user to add the resources manually, unless we want to parse the snapshot files.

Oh, wait, actually, this won't we too hard. If .molj is really just plain text json, we can use https://quarto.org/docs/extensions/lua.html#json-encoding!

@BradyAJohnston
Copy link
Contributor Author

Would this run before or after the files are moved / rendered into another directory?

local molj = quarto.json.decode(readFile(url))

If after we still run into the same problem as before

@jmbuhr
Copy link
Owner
jmbuhr commented Aug 17, 2022

For self-included filters one can specify if they should run before or after the quarto filter: https://quarto.org/docs/extensions/filters.html#activating-filters, but I am not sure if this is possible to specify for shortcodes and within an extension. And as it turns out my first instinct that resources would be handled by one of the quarto builtin lua filters is wrong anyways. It is handled by their typescript code: https://github.com/quarto-dev/quarto-cli/blob/aa8d33fa2b873e5f8e73ecfdc1582ee3c94236d0/src/command/render/render.ts via https://github.com/quarto-dev/quarto-cli/blob/aa8d33fa2b873e5f8e73ecfdc1582ee3c94236d0/src/command/render/resources.ts

I think the resources processing happens after pandoc's render, so after the filters.

@jmbuhr
Copy link
Owner
jmbuhr commented Aug 17, 2022

The coresponding question to the quarto devs is at: quarto-dev/quarto-cli#1938

@jmbuhr
Copy link
Owner
jmbuhr commented Aug 17, 2022

Looks like quarto.doc.addHtmlDependency should work to add resources at runtime as well :)

@jmbuhr jmbuhr mentioned this issue Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants