quarto-dev / quarto-dev/quarto-cli
Markdown in custom listing fields not rendered by EJS template
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
Bug description
Following the "Metadata Listings" section in the documentation, it is possible to include custom metadata in YAML, either in individual files or in front matter, and have that metadata show up in a custom listing template.
For instance, we can create a listing page:
index.qmd
---
title: "Testing"
template: custom.ejs
contents:
- name: First Item
href: https://www.quarto.org
custom-field: A **custom value**
- name: Second Item
href: https://www.rstudio.org
custom-field: A *second* custom value
---
Blah
…and a custom EJS template:
custom.ejs
```{=html}
<ul>
<% for (const item of items) { %>
<li>
<a href="<%- item.href %>"><%= item.name %></a><br/>
<%= item['custom-field'] %>
</li>
<% } %>
</ul>
```
…and it will render the custom field in an HTML list:
<ul>
<li>
<a href="https://www.quarto.org/">
First Item
</a><br>
A **custom value**
</li>
<li>
<a href="https://www.rstudio.org/">
Second Item
</a><br>
A *second* custom value
</li>
</ul>
However, any Markdown formatting in the custom field is not rendered—it renders the text as A **custom value** instead of A <strong>custom value</strong>
It could be helpful to have a helper function of sorts accessible by EJS files, like
<%= parseMarkdown(item['custom-field']) %>
Rendering works as expected when raw HTML is used in the metadata. That is,
- name: First Item
href: https://www.quarto.org
custom-field: A <strong>custom value</strong>
… turns into
<li>
<a href="https://www.quarto.org/">
First Item
</a><br>
A <strong>custom value</strong>
</li>
This is with Quarto 1.3.26 in RStudio 2022.07.2+576 (and also in VS Code) on macOS Monterey 12.6
Checklist
- Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
- Please format your issue so it is easier for us to read the bug report.
- Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
- Please document the operating system you're running. If on Linux, please provide the specific distribution.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Use index.qmd and custom.ejs as the minimal reproduction, then inspect the custom listing and EJS rendering path first. Completion means Markdown in custom-field is converted to HTML in the generated list, while the existing raw HTML behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, markdown
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100