Ensure page titles from rendered Markdown do not contain any markup#3546
Closed
waylan wants to merge 2 commits intomkdocs:masterfrom
Closed
Ensure page titles from rendered Markdown do not contain any markup#3546waylan wants to merge 2 commits intomkdocs:masterfrom
waylan wants to merge 2 commits intomkdocs:masterfrom
Conversation
While the `_ExtractTitleTreeprocessor` already extracts text from the etree, postprocessors may add more markup. Therefore, markupsafe's `striptags` is used to ensure all markup is removed. Conveniently, `markupsafe` is already a dependency and available. Fixes mkdocs#3357.
Member
Author
|
Hmm, the failing lint check seems nonsensical to me. Not sure what to do there. |
Contributor
|
The suggestion is correct because that is a third party package and currently it is in the standard library block. |
waylan
commented
Jan 30, 2024
| pg.read_source(cfg) | ||
| pg.render(cfg, fl) | ||
| self.assertEqual(pg.title, '*Hello — beautiful world') | ||
| self.assertEqual(pg.title, '*Hello — beautiful world') |
Member
Author
There was a problem hiding this comment.
I'm not convinced this behavior is desired here. I expect we do not want HTML entities to be unescaped. If so, we will need to clone the striptags function and eliminate the call to unescape. See this comment for more.
This was referenced Jan 31, 2024
Closed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
While the
_ExtractTitleTreeprocessoralready extracts text from the etree, postprocessors may add more markup. Therefore, markupsafe'sstriptagsis used to ensure all markup is removed. Conveniently,markupsafeis already a dependency and available. Fixes #3357.