fix(website-listing): Avoid type error if item.description
is not a string
#12548
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.
Description
When using custom listings with a custom template, e.g.
template authors control how the contents are processed and may make odd decisions like including an item like this:
Their template code is handling the rendering, so they may process
item.description
conditionally and thenull
is an okay value.However, Quarto's internal
isPlaceHolder(item.description)
calls.match()
on the description, which may not be a string, causing a type error.This PR fixes this by checking not just that
item.description
is defined but also that it's a string before callingisPlaceholder()
.(Sidenote: I'm not sure why this code path is triggered in the presence of a custom listing template, but I'm confident this would avoid the type error I encountered.)
Checklist
I have (if applicable):