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
Trouble escaping a Hugo paired shortcode #5902
Comments
@mcanouil it is not really Hugo related. I don't know what the hugo tag means, but it is not related to the Hugo output format. I don't think it applies here. This is about shortcodes itself. The stack trace is
The issue is that we are parsing shortcode during our Qmd processing in Typescript before any Lua is happening. And so the escaping of shortcode does not apply using the attributes.
If we use the shorter syntax using triple curly braces, there is no issue. ---
title: "Sidenotes"
format: html
---
```md
{{{< gallery >}}}
{{{< figureforgallery src="search2.png" alt="Screenshot of r-universe simple search results." >}}}
{{{< figureforgallery src="search3.png" alt="Screenshot of r-universe advanced search query." >}}}
{{{< figureforgallery src="search4.png" alt="Screenshot of r-universe advanced search results." >}}}
{{{< /gallery >}}}
```
We document escaping of shortcodes here: https://quarto.org/docs/extensions/shortcodes.html#escaping It seems to be the only method that works. @cscheid do you think the |
@cderv I figured that much while testing on the repo. |
It is not that simple I think. The problem is that our parsing @cscheid is the one knowing the internal of all this and IMO can say if known limitation or an issue to fix |
Note that the regex, in the following code, does not allow a shortcode to start with
This changes was implemented in #4009 Weirdly, there is no 1.3.116 tag |
Interesting history ! Though I don't think this is the issue here, or at least the question to be answered. Let me clarify as I don't want this issue to be misunderstood.
I don't think shortcode with leading Even if this was valid, should the shortcode validity be checked when inside a shortcode-escaped codeblock ? So under the assumption, the regex is ok., this is expected to be invalid here. The So the error is ok. There should be an error if However, our parser will check each line, and Should this really be run also on codeblocks with our |
Exactly, this is what I meant in #5902 (comment)
Thus 😉
The change in the regex is the reason it was "working" before and it is no longer working. |
By the way, I can imagine a code block with escaped shortcodes, where one would willingly present wrong shortcodes for teaching what not to do. So that'd be an argument for not checking shortcodes when |
This comment was marked as outdated.
This comment was marked as outdated.
Ok, I'm having a slow day, I apologize. The bug is where @cderv said originally... I'm on it, will fix soon. |
PR open. Thanks for the report, the fix should be in soon! |
* support closing shortcodes cf hugo syntax. Closes #5902 * smoke test * changelog * changelog
Thank you!! |
hey there all! i'm running into this same issue as @maelle using quarto (with hugo) for pyOpenSci. I thought that "protecting" the shortcodes with ```{=markdown} might work as it did in 1.2 but that doesn't seem to be the case. applying triple brackets {{{ shortcode here }}} does work but will i have to go in and fix every single shortcode now and add another set of brackets??
Is there perhaps another trick to ensuring this works? i didn't see anything in the quarto docs. |
@lwasser I apologize. This used to be a quarto "bug", where we ignored shortcodes inside code blocks. Unfortunately, some users need those shortcodes to be resolved, and so we fixed that bug. But you clearly have a document with lots of shortcodes that you don't want to process in code contexts. I don't think we have a way to ignore those, but I see the value in implementing one. Can you share a full document where this comes up so that we can figure out how to fix this properly? Thanks. |
hey there @cscheid thank you. i am actually having a handful of issues with my quarto builds. i did email Christophe about it just so you know. should i open a new issue? the PR is here - data-science-skills/dss-web#8 i'm essentially rebuilding a pure quarto site into a quarto/hugo site for flexibility. but i'm running into a lot of issues with images not rendering, shortcode issues, etc. some of these things worked in older versions of quarto and are broken now. the pr is here - data-science-skills/dss-web#8 please let me know if i should open a new issue somewhere. it seems like the shortcode issue is fixed by BOTH using the {=markdown} safetly net (maybe i don't need that anymore?) and triple |
I confess it's going to be hard for me to go through the 594 changed files in that PR, sorry! The smaller the broken example, the faster we can get it fixed. |
@lwasser I'll get back to you next week about the PR and all your issues ! |
Ok thank you all! I understand that is a huge pr. It's essentially moving the site from quarto to quarto hugo. So it includes theme files and such. But I can't merge it until the build actually works so the website builds. Thank you @cderv for the reply! I'll hang tight and if I can provide something specific for you please say the word!! |
@cscheid this is the type of content in @lwasser website {{< noticeowl "learn" >}}
After completing this page, you will be able to:
* Understand how dependency management can play a large role in **Python** programming.
* Explain how to use **conda** environments to manage your third party libraries.
{{< /noticeowl >}}
Those are shortcode for Hugo. Escaping using Maybe we could bring an equivalent to ::: {shortcodes=false}
content
::: this would deactivate shortcode parsing by Quarto in the whole block. Would it be possible ? No matter how we do it, this will be common in Also ur docs says (https://quarto.org/docs/output-formats/hugo.html#shortcodes)
But it does not seem to be the case anymore. I'll open an issue about that one... (see #7108) |
would it be possible to update this page - in the docs to suggest using
instead of
or maybe to clarify as perhaps i just read that page incorrectly? many thank y'all. |
To be clear, this does not exists yet
and this ```{=markdown}
[click here]()
``` is still useful to keep some Markdown content, unprocessed by Pandoc. This is a bit different than shortcode... We'll update the doc anyway depending on #7108 |
I'll set aside some time this week to fix this. The problem is that shortcode parsing is quite brittle because it needs to happen ahead of Pandoc parsing (it's in qmd-reader.lua, effectively). It's not easy code to fix. |
Bug description
We have a Quarto book where we document how to write blog posts on our Hugo website. With the pre-release version of Quarto (and the released version, but not with
1.3.49
that I have locally) the build fails because of the chunk below:The error is
ERROR: invalid shortcode: /gallery
.Steps to reproduce
I've set up a reprex at https://github.com/maelle/quartohugo It's the default Quarto book created with RStudio IDE (Create New Project > Quarto book) except I tweaked https://github.com/maelle/quartohugo/blob/main/index.qmd to include the faulty chunk.
I added a GHA workflow https://github.com/maelle/quartohugo/blob/main/.github/workflows/render.yaml The latest log is at https://github.com/maelle/quartohugo/actions/runs/5253624754/jobs/9491184540
Expected behavior
The book should be built and the shortcode should appear as is in code.
Actual behavior
There is an error
ERROR: invalid shortcode: /gallery
.Your environment
ubuntu-latest on GHA
Quarto check output
I'm using the official Quarto GitHub Action so hopefully it's fine I don't answer this!
The text was updated successfully, but these errors were encountered: