-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Hotfix Expression language example lower than #17587
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
Hotfix Expression language example lower than #17587
Conversation
@@ -41,7 +41,7 @@ way without using PHP and without introducing security problems: | |||
article.commentCount > 100 and article.category not in ["misc"] |
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.
So we should fix this, too, right?
I am wondering if we should keep the >
and not use <
and fix the docs builder instead, because we are in a .. code-block:: text
.
WDYT @weaverryan ?
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.
Woh. This is kind of "spooky". On the target page - https://symfony.com/doc/current/components/expression_language.html#how-can-the-expression-engine-help-me - the >
renders fine here. It even renders as >
in the page source. It is only the <
below that is missing - completely unrendered on the page.
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.
@nikophil as you worked a lot on the docs-builder, maybe do you have an idea?
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.
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 may be a highlight.js issue ? <pre class="hljs text">
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.
ok I found where the problem is coming from in the docs builder.
For symfony.com, files are rendered as fjson
files: we loop on each html file, take the content of the <body>
tag thanks to symfony/dom-crawler
and put it in a fjson
file.
The symbol <
disappears after the crawler step (it might assume it is an error in the html syntax? don't really know 🤷)
Here, the content of file_get_contents()
has the symbol, but it's not present anymore in $crawler->filter('body')->html()
There may be two solutions for this:
- fix the problem in
symfony/dom-crawler
(ie: don't modify code inside<pre>
tags?) - extract
<body>
tag content without dom crawler
@weaverryan any thoughts?
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.
<pre>product.stock < 15 </pre>
seems to be an invalid html (tested on https://jsonformatter.org/html-validator)
Here we use code-block text but when it's code-block
is xml
<
is encoded.
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.
😮
W3C validator says the same thing: <
is invalid inside a <pre>
whereas >
is valid
I was always thinking <pre>
would allow everything
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre
If you have to display reserved characters such as <, >, &, and " within the <pre> tag, the characters must be escaped using their respective HTML entity.
maybe the right thing to do would be to automate this replacement in code blocks
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've provided a fix on the builder:
symfony-tools/docs-builder#145
actually the problem only occurred on .. code-block:: text
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.
Thank you 😃
This PR was merged into the main branch. Discussion ---------- fix: escape special chars in code text Hello there! here is a fix for symfony/symfony-docs#17587 I had hard time understanding the problem was only occurring for code of type "text"! cheers! Commits ------- 3407885 fix: escape special chars in code text
Thanks Antoine ... but I'm closing this one without merging because @nikophil fixed the underlying issue in the Symfony Docs Builder and we tagged a new version: https://github.com/symfony-tools/docs-builder/releases/tag/v0.18.10 I just updated it on symfony.com too, so this should be solved the next time that docs are rebuild. Thanks to all reviewers too. Fixing this was a nice team effort! 💪 |
No problem, thank you @nikophil ! |
On this page https://symfony.com/doc/current/components/expression_language.html#how-can-the-expression-engine-help-me
product.stock < 15
is not correctly displayed. I seeproduct.stock 15
Examining html code is
<code>...product.stock 15</code>
.Locally generated code is
<pre class="hljs text">...product.stock < 15...</pre>
I found some places where
<
is used, I think it could fix rendering.There is no other .rst file where
<
is used