Skip to content

Commit 612e00b

Browse files
committed
[TASK] Forward directive options to node
This enables themes to define additional options that can then be used in the theme, for example additional information for code-nodes. This also fixes an undetected bug in graphs where the width option was swalloed
1 parent ab1a282 commit 612e00b

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

packages/guides-restructured-text/src/RestructuredText/Parser/Productions/DirectiveRule.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,22 @@ private function parseDirectiveContent(Directive $directive, BlockContext $block
153153
*/
154154
private function postProcessNode(Node $node, array $options): Node
155155
{
156+
$optionsForNode = [];
156157
foreach ($options as $option) {
157-
if ($option->getName() !== 'class' || !is_string($option->getValue()) || $option->getValue() === '') {
158+
if (!is_string($option->getValue())) {
158159
continue;
159160
}
160161

161-
$node->setClasses(array_merge($node->getClasses(), explode(' ', (string) $option->getValue())));
162+
if ($option->getName() === 'class') {
163+
$node->setClasses(array_merge($node->getClasses(), explode(' ', (string) $option->getValue())));
164+
continue;
165+
}
166+
167+
$optionsForNode[$option->getName()] = $option->getValue();
162168
}
163169

170+
$node = $node->withOptions(array_merge($optionsForNode, $node->getOptions()));
171+
164172
return $node;
165173
}
166174

tests/Integration/tests/graphs/plantuml-external/expected/Plantuml/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ <h1>Uml Directive</h1>
44

55
<figure
66
class="uml-diagram"
7-
>
7+
style="width: 1000" >
88
75038c5ec593504a90a100f9668e1138
99
<figcaption>Figure 1-1: Application flow</figcaption></figure>
1010
<figure
1111
class="uml-diagram"
12-
>
12+
style="width: 1000" >
1313
75038c5ec593504a90a100f9668e1138
1414
<figcaption>Figure 1-1: Application flow</figcaption></figure>
1515
</div>

tests/Integration/tests/graphs/plantuml-external/expected/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ <h1>Uml Directive</h1>
44

55
<figure
66
class="uml-diagram"
7-
>
7+
style="width: 1000" >
88
75038c5ec593504a90a100f9668e1138
99
<figcaption>Figure 1-1: Application flow</figcaption></figure>
1010
<figure
1111
class="uml-diagram"
12-
>
12+
style="width: 1000" >
1313
75038c5ec593504a90a100f9668e1138
1414
<figcaption>Figure 1-1: Application flow</figcaption></figure>
1515
<div class="toc">

tests/Integration/tests/toctree/toctree-maxdepth/expected/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ <h1>Index</h1>
242242

243243
</ul>
244244
</div>
245+
245246
<p>Glob</p>
246247
<div class="toc">
247248
<ul class="menu-level">

0 commit comments

Comments
 (0)