-
Notifications
You must be signed in to change notification settings - Fork 25
Add support for figures with custom CSS classes #140
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
Add support for figures with custom CSS classes #140
Conversation
src/Renderers/FigureNodeRenderer.php
Outdated
public function render(): string | ||
{ | ||
var_dump('here');exit; | ||
return $this->templateRenderer->render('figure.html.twig', [ |
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.
Does figureNode->getCssClasses() not have anything here?
Something curious: in the $nodeRendererFactories[FigureNode::class] = new CallableNodeRendererFactory(
function (FigureNode $node) {
return new Renderers\FigureNodeRenderer(
$node,
$this->templateRenderer
);
}
); If I put a |
Hmm, yea. That is curious. I don't remember how that stuff works. However, most directives, I believe, ( That's what I would try here |
Thanks for the insights. I tried what you suggested, but it's not working. It doesn't even reach to this |
src/Directive/FigureDirective.php
Outdated
use Doctrine\RST\Nodes\Node; | ||
use Doctrine\RST\Parser; | ||
|
||
class FigureDirective extends Directive |
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.
Change this to a SubDirective
- THEN your processSub()
should be called. A SubDirective is one where you want the "inside" of the directive to be parsed like the rest of RST - https://github.com/doctrine/rst-parser/blob/9107ba8b1dc8dc2dda2438cd38c609c74d2c33fe/lib/Directives/SubDirective.php#L12-L20
Apparently we even wrote in SubDirective that figure
is an example of one: https://github.com/doctrine/rst-parser/blob/9107ba8b1dc8dc2dda2438cd38c609c74d2c33fe/lib/Directives/SubDirective.php#L59
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.
Thanks for your continuous help 🙏 Sadly I still can't make this work.
I've fixed this! It should really be fixed upstream, but I'm short on time and wanted to get it working for you. |
Merged! Ryan, thanks a lot for fixing this. |
In Symfony Fast Track book we use things like this:
Current parser translates it to:
But we need this:
We need that because
with-browser
class adds a "fake browser" window wrapping the image. But that fake browser is made with CSS::before
and::after
pseudo-elements, which don't work for<figure>
or<img>
and that's why we need the wrapping<div>
.Sadly, and as usual, I don't know what I'm doing and it doesn't work, so I'd need your help. Thanks!