-
Notifications
You must be signed in to change notification settings - Fork 25
Add support for tilde characters #181
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
Conversation
doctrine/rst-parser parses |
even worse, I see no way of escaping a |
Maybe it would make sense to investigate migrating to |
We're already working on this (see https://github.com/wouterj/symfony-docs-guides), but more work is needed here (especially around ordering documents). |
I've pushed a not-so-nice workaround to this PR. I don't see any other way to escape the tilde, and it should be safe given this is the Symfony docs specific builder. |
|
||
$rendered = parent::render(); | ||
|
||
return str_replace('__TILDE__', '~', $rendered); |
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.
Let's hope that we won't have content containing the actual text __TILDE__
in the symfony documentation (or the documentation of other projects built with this builder).
Maybe we should check for __TILDE__
in the spanValue before doing the ~
replacement and failing explicitly instead of producing a wrong output (or even smarter: selecting another non-conflicting placeholder in that case, but that might not be worth 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.
It's probably safe to use this ... but if we want to assure this, we could use more underscores instead of only 2.
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.
Well, I would add least add the safety check to rebuild a build failure in case the assumption is not actually safe (instead of waiting for someone to discover that some obscure page has content not rendered like the source:
if (str_contains($spanValue, '__TILDE__')) {
throw new \Exception('Cannot render content containing the text "__TILDE__" as it is used as a special placeholder in the build.');
}
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.
@stof OK, I've added your code while merging as an extra protection measure. Thanks!
Thanks @wouterj for this contribution. Yes, I think this is a reasonable solution while we keep using the old RST parser. Thanks! |
This is now merged. Wouter, thanks for providing a solution for this. |
Related to
This PR adds a failing test that shows the issue. This is the output change that would make test pass: