-
Notifications
You must be signed in to change notification settings - Fork 332
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
fix: Markdown support in listings templates #11760
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
f9a5250
fix: Markdown is no longer supported in listings (>= 1.7.5)
mcanouil 4b4c36b
revert: unwanted change
mcanouil 0f779cf
fix: use markdown div thus no raw block
mcanouil 911207e
refactor: use markdown syntax
mcanouil 8463bc7
revert: use raw block to avoid "p"
mcanouil 0af2dd7
fix: typo in div code
mcanouil 5d1ef85
refactor: put if/else inside code block
mcanouil 0aafe42
fix: use raw block for localizedString and don't escape content
mcanouil 43ff451
fix: use raw block instead of inline
mcanouil f03ee1e
fix: no need to escape
mcanouil d52e2ba
fix: no need to escape base64 value
mcanouil 2b73ea2
test: styles.sccs does not exist
mcanouil 61094dd
Merge branch 'main' into fix/issue11758
mcanouil 9c43d63
fix: ensure no extra`<p>` tag is added
mcanouil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<div class="listing-no-matching d-none"><%- listing.utilities.localizedString("listing-page-no-matches")%></div> | ||
<% if (listing["page-size"] < items.length) { %> | ||
```{=html} | ||
<div class="listing-no-matching d-none"><%= listing.utilities.localizedString("listing-page-no-matches") %></div> | ||
<% if (listing["page-size"] < items.length) { %> | ||
mcanouil marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<nav id="<%- listing.id %>-pagination" class="listing-pagination" aria-label="Page Navigation"> | ||
<ul class="pagination"></ul> | ||
</nav> | ||
``` | ||
<% } %> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
src/resources/projects/website/listing/listing-default.ejs.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
:::{.list .quarto-listing-default} | ||
``````{=html} | ||
::: {.list .quarto-listing-default} | ||
|
||
<% for (const item of items) { %> | ||
<% partial('item-default.ejs.md', {listing, item, utils }) %> | ||
<% } %> | ||
`````` | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localizedString()
usage here will insert a user provided value. I think it is safer to keep using<%-
here, especially when used in HTML attribute, as we can't know which character would be used.Maybe there won't be any
<
used forlisting-page-order-by
but if so, then I think it could break HTML.That is my thinking. If there is a specific reason, I am missing it, so I would really like to understand and learn something new. Why replacing ?
My first though is that using
%<-
for escaping is safer.Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value is used inside text attribute or inside div which means the content is directly displayed to the users.
Escaping what's supposed to be a string would lead to weird
placeholder
,aria-label
, andoption
text display.Why would the text need escaping? I might have missed something but to me, there are no reasons to escape those values.
Both "work" and both can lead to unexpected outputs when non ASCII string provided.
I don't think there is a perfect solution. The rational being the use of
=
was the same as the overall PR, i.e., allow Markdown/HTML (of course no markdown evaluation is possible anyway when inside raw block).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding of this
<%-
vs<%=
in template is thatMaybe this won't ever happen but I was thinking it is safer to always HTML escape
<%-
when we know the content provided shouldn't be interpreted as HTML structure.Example in lodash doc #11787 is quite explicite about escaping
If you want to write
<script>
as such in strong case, then you need the template to HTML escape the value.So for language customizable value, I am thinking it is better to protect if a user wants to use something like quotes (
"
) in the value.Maybe I am wrong about this but I think my thinking sum up
<%-
would be safer as this is why it was used before. Maybe it is not useful but it does not harm to use it<%=
, especially if it could potentially be opened to regression.🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As all the occurrences are in an HTML raw block, I think we can go (back) with
<%-
as no markdown will ever work there.Should I do the PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To keep on the purpose of learning, as this is still unclear, can you explain to me
Or rather you'll confirm if I understand correctly
I think this is what I was missing, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably update the documentation about all this story:
https://quarto.org/docs/websites/website-listings-custom.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and made a PR:
<%-
) forlisting.utilities.localizedString()
#11817There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also opened a documentation issue: