listing - Correctly handle non ASCII category and special characters #11397
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.
This is additional fix to #11177 so that category with special characters, and UTF-8 characters are correctly handled.
It fixes first #11358 and then add to #11177 to fix #8517. A category with apostrophe does not cause issue anymore (#10829) but cliking on them was still not working.
About UTF-8 in category
Using base64 encoding works, in the limite of ASCII character range. For content with UTF-8 characters, we need to take extra measure.
This PR uses
encodeURIComponent
anddecodeURIComponent
to get into that range of characters. It seems UTF-8 stream can be used, so we could switch to that.About clicking on category with special char
It took me a while to find the problem but the issue was that
categories
are metadata processed by us in JS, but also passed to Pandoc to use in title-block template.Pandoc parses any string value in metadata as Markdown, and we default to
markdown+smart
for the readers. This smart extension applies and so'
was transformed to another character.This lead to our JS script not being able to find the right category to activate because they are not the same when base64 encoded.
Example
Render to native
\8217
is not'
We had such issues in the past with
revealjs-url
metadata, so I am using same "trick" by wrapping inpandocNativeStr()
so that it can be passed unparsed as a metadata to Pandoc.This requires processing the format metadata to override the existing one. To do that
projectExtras
as this really apply to website project.metadataOverride
though because currentlymergeConfigs
is appending arrays together otherwise.engineMetadata
override. As discussed in the past, I think this should be removed, but that it is not the place to discuss. Fact iscategories
is not listed as aisQuartoMetadata()
so, it does get identified as possible engine metadata override, but it can't happen here as we are processing it. So like revealjstheme
key, there is an exception now. This whole part will need to be reconsider when we'll deal withmergeConfig
and this code pieceHopefully this explains clearly what I tried. Happy to discuss and consider another solution if you think of one.
Consequence of this change:
categories
can only be raw string, as in non-markdown string. Which I think is what we currently expect (but not enforced until now)