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

Quarto hugo-md rendering doesn't work with shortcodes with named arguments #10292

Closed
ryarazi opened this issue Jul 14, 2024 · 3 comments · Fixed by #11149
Closed

Quarto hugo-md rendering doesn't work with shortcodes with named arguments #10292

ryarazi opened this issue Jul 14, 2024 · 3 comments · Fixed by #11149
Assignees
Labels
bug Something isn't working shortcodes issues related to shortcodes
Milestone

Comments

@ryarazi
Copy link

ryarazi commented Jul 14, 2024

Bug description

When trying to render quarto .qmd into an .md for a hugo website I get a bug where the names of named arguments are removed from shortcodes.

Steps to reproduce

When I run quarto render on:

---
title: "Test"
format: hugo-md
---

```{=markdown}
{{< vimeo id="146022717" class="my-vimeo-wrapper-class" title="My vimeo video" >}}
```

Expected behavior

I expect to get:

---
title: "Test"
format: hugo-md
---

{{< vimeo id="146022717" class="my-vimeo-wrapper-class" title="My vimeo video" >}}

Actual behavior

Instead the resulting file is:

---
title: Test
format: hugo-md
---


{{< vimeo "146022717" "my-vimeo-wrapper-class" "My vimeo video" >}}

Your environment

OS: Ubuntu 24.04 LTS using Windows WSL

Quarto check output

Quarto 1.5.54
[✓] Checking versions of quarto binary dependencies...
      Pandoc version 3.2.0: OK
      Dart Sass version 1.70.0: OK
      Deno version 1.41.0: OK
      Typst version 0.11.0: OK
[✓] Checking versions of quarto dependencies......OK
[✓] Checking Quarto installation......OK
      Version: 1.5.54
      Path: /opt/quarto/bin

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

[✓] Checking LaTeX....................OK
      Tex:  (not detected)

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

[✓] Checking Python 3 installation....OK
      Version: 3.12.3
      Path: /home/me/venv/bin/python3
      Jupyter: 5.7.2
      Kernels: python3, dev, julia-1.10

[✓] Checking Jupyter engine render....OK

[✓] Checking R installation...........(None)

      Unable to locate an installed version of R.
      Install R from https://cloud.r-project.org/
@ryarazi ryarazi added the bug Something isn't working label Jul 14, 2024
@ryarazi ryarazi changed the title Quarto hugo-md rendering doesn't work with shortcodes with named positionals Quarto hugo-md rendering doesn't work with shortcodes with named arguments Jul 14, 2024
@cderv
Copy link
Collaborator

cderv commented Jul 15, 2024

Thanks for the report.

Our pre-shortcode-filter are currently processing this syntax. And it seems to happen even for unknown shortcode. Somehow, the attribute names are removed 🤔

Extract for the trace json showing shortcode replacement
Filter: normalize-table-merge-raw-html (no op)
Doc
meta:
  toc-title: "Table of contents"
  title: "Test"
  header-includes: []
  revealjs-plugins: []
  biblio-config: true
  include-after: []
  labels:
    modified: "Modified"
    abstract: "Abstract"
    affiliations: "Affiliations"
    published: "Published"
    related_formats: "Other Formats"
    doi: "Doi"
    description: "Description"
    authors: "Authors"
    keywords: "Keywords"
  include-before: []
pandoc-api-version: "1,23,1"
blocks:
  - t: "RawBlock"
    format: "markdown"
    text: "{{< vimeo id=\"146022717\" class=\"my-vimeo-wrapper-class\" title=\"My vimeo video\" >}}"
  - t: "Div"
    attr: "('3ade8a4a-fb1d-4a6c-8409-ac45482d5fc9', ['hidden'], [])"
    content: []

<--- NO OP HERE --->

Filter: pre-shortcodes-filter
Doc
meta:
  toc-title: "Table of contents"
  title: "Test"
  header-includes: []
  revealjs-plugins: []
  biblio-config: true
  include-after: []
  labels:
    modified: "Modified"
    abstract: "Abstract"
    affiliations: "Affiliations"
    published: "Published"
    related_formats: "Other Formats"
    doi: "Doi"
    description: "Description"
    authors: "Authors"
    keywords: "Keywords"
  include-before: []
pandoc-api-version: "1,23,1"
blocks:
  - t: "RawBlock"
    format: "markdown"
    text: "{{< vimeo \"146022717\" \"my-vimeo-wrapper-class\" \"My vimeo video\" >}}"
  - t: "Div"
    attr: "('3ade8a4a-fb1d-4a6c-8409-ac45482d5fc9', ['hidden'], [])"
    content: []
Ops

  - op: "replace"
    path: "/blocks/0/text"
    value: "{{< vimeo \"146022717\" \"my-vimeo-wrapper-class\" \"My vimeo video\" >}}"

Escaping shortcode: https://quarto.org/docs/extensions/shortcodes.html#escaping seems to work here.

```{=markdown}
{{{< vimeo id="146022717" class="my-vimeo-wrapper-class" title="My vimeo video" >}}}
```

Anyhow, for hugo-md escaping seems to be the key here - though this is a change from what we documented for Hugo https://quarto.org/docs/output-formats/hugo.html#shortcodes

Note that Hugo shortcodes and Quarto shortcodes share the same basic syntax (e.g. {{< var foo >}}). This is normally not a problem as shortcodes not recognized by Quarto are passed through unmodified to Hugo.

Not the case anymore.

We should probably at least update the doc, or fix if this is unintended.

@cderv cderv added triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. shortcodes issues related to shortcodes labels Jul 15, 2024
@cderv
Copy link
Collaborator

cderv commented Jul 15, 2024

It seems we reconstruct the shortcode when unknown, but we are missing the raw_args names from lst

local handler = handlerForShortcode(shortcode_struct)
if handler == nil then
return open .. space .. name .. " " .. table.concat(raw_args, " ") .. " " .. close
end

@cscheid
Copy link
Collaborator

cscheid commented Jul 16, 2024

Definitely a bug we need to fix. I'm surprised about the raw_args behavior, those should not be touching named args at all.

@cscheid cscheid removed the triaged-to Issues that were not self-assigned, signals that an issue was assigned to someone. label Jul 16, 2024
@cscheid cscheid added this to the v1.6 milestone Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working shortcodes issues related to shortcodes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants