Custom listing appears to break with certain kinds of HTML #11769
Replies: 13 comments
-
In the real version I wrote where I discovered this, I also had the same problems with <div>
<div>
<% for (const item of items) { %>
<a href="<%- item.path %>" class="my-item">
<p>
<%= item.title %>
</p>
</a>
<% } %>
</div>
</div> |
Beta Was this translation helpful? Give feedback.
-
For there most part I'm able too substitute other elements for <p class="test-listing-main">
<ul class="test-listing-container">
<% for (const item of items) { %>
<li class="test-listing-item">
<a href="<%- item.path %>"></a>
</li>
<% } %>
</ul>
</p> Rendered HTML (I've run in through a formatter to make the indentation clearer): <div
id="listing-projects-oss"
class="quarto-listing quarto-listing-container-custom"
>
<p class="test-listing-main"></p>
<ul class="test-listing-container">
<li class="test-listing-item">
<a href="../projects/oss/unswthesisdown/index.html"></a>
</li>
<li class="test-listing-item">
<a href="../projects/oss/stickylabeller/index.html"></a>
</li>
<li class="test-listing-item">
<a href="../projects/oss/collateral/index.html"></a>
</li>
<li class="test-listing-item">
<a href="../projects/oss/columnflow/index.html"></a>
</li>
<li class="test-listing-item">
<a href="../projects/oss/sverto/index.html"></a>
</li>
<li class="test-listing-item">
<a href="../projects/oss/ggflags/index.html"></a>
</li>
<li class="test-listing-item">
<a href="../projects/oss/closeread/index.html"></a>
</li>
<li class="test-listing-item">
<a href="../projects/oss/weatheroz/index.html"></a>
</li>
</ul>
<p></p>
<div class="listing-no-matching d-none">No matching items</div>
</div> |
Beta Was this translation helpful? Give feedback.
-
Surprisingly this does work as expected! Perhaps I was too hasty in saying the problem is with <div class="test-listing-main">
<ul class="test-listing-container">
<% for (const item of items) { %>
<li class="test-listing-item">
<a href="<%- item.path %>"></a>
</li>
<% } %>
</ul>
</div> |
Beta Was this translation helpful? Give feedback.
-
Are you using raw code block? https://quarto.org/docs/authoring/markdown-basics.html#raw-content |
Beta Was this translation helpful? Give feedback.
-
@mcanouil Are raw blocks required inside of EJS templates? |
Beta Was this translation helpful? Give feedback.
-
EJS files are read as Markdown which can explain your parsing issue because Pandoc needs to guess it's HTML. |
Beta Was this translation helpful? Give feedback.
-
Oh, wow! Do you know how I can mark section of the EJS file as raw HTML? Or should I just write the whole thing as Pandoc Markdown and use fenced divs? |
Beta Was this translation helpful? Give feedback.
-
Both as not all can be (easily) written as Markdown and see the link I shared previously. |
Beta Was this translation helpful? Give feedback.
-
Thanks @mcanouil, I'll give it a crack! |
Beta Was this translation helpful? Give feedback.
-
Beware that any EJS variables inside raw block won't be read as Markdown thus be evaluated. (That's currently an issue with 1.7.5 listings where raw blocks were added to avoid Pandoc memory issues likely caused by its way to try to parse HTML) |
Beta Was this translation helpful? Give feedback.
-
I've wrapped the contents of the EJS file in a raw HTML block and it seems to work quite well now 😊 Thanks @mcanouil! |
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
I wonder if the Custom Listing documentation should be updated to mention that EJS templates are processed as Markdown. Markdown isn't mentioned at all, and the example given only uses HTML. Statements like these also heavily imply that we should expect the template to emit HTML rather than Markdown:
|
Beta Was this translation helpful? Give feedback.
-
Bug description
Consider a basic Quarto site, with
_quarto.yml
:And
index.qmd
:If I add a
listing.ejs
based on the example in the docs, it works fine. Here I've modified it to wrap eachitem.title
in ap.test-class
:But if I change the
p
todiv
, the listing breaks, rendering the contents of the for loop as a code block:If I use an online tool to validate the EJS, it seems fine.
Your environment
Quarto check output
Beta Was this translation helpful? Give feedback.
All reactions