Skip to content

Commit dd43d4b

Browse files
authored
Merge pull request #56 from jrushlow/fix/admonition-expectations
fix admonition expectations && add default class attribute
2 parents 9b1f81f + bbbcb19 commit dd43d4b

File tree

13 files changed

+88
-75
lines changed

13 files changed

+88
-75
lines changed

src/Directive/AdmonitionDirective.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ public function processSub(Parser $parser, ?Node $document, string $variable, st
2020
$wrapperDiv = $parser->renderTemplate(
2121
'directives/admonition.html.twig',
2222
[
23-
// a bit strange, but on the old markup we literally
24-
// had a class of 'admonition-"
25-
'name' => '',
23+
'name' => 'default',
2624
'text' => $data,
2725
'class' => $options['class'] ?? null,
2826
]

src/Templates/default/html/directives/admonition.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{# icons are from https://heroicons.com/ - MIT License #}
2-
<div class="admonition admonition-{{ name }} {{ class ?? '' }}">
2+
<div class="admonition admonition-{{ name }} {{ class }}">
33
<p class="admonition-title">
44
{% if name in ['admonition', 'note'] %}
55
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" /></svg>

tests/fixtures/expected/blocks/directives/admonition.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
<meta charset="utf-8" />
55
</head>
66
<body>
7-
<div class="admonition-wrapper screencast_class">
8-
<div class="admonition admonition-">
9-
<p class="admonition-title">Screencast</p>
10-
<p>Do you prefer video tutorials? Check out the the screencasts.</p>
11-
</div>
7+
<div class="admonition admonition-default screencast_class">
8+
<p class="admonition-title"> Screencast </p>
9+
<p>Do you prefer video tutorials? Check out the the screencasts.</p>
1210
</div>
1311
</body>
1412
</html>

tests/fixtures/expected/blocks/directives/best-practice.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
<meta charset="utf-8" />
55
</head>
66
<body>
7-
<div class="admonition-wrapper">
8-
<div class="admonition admonition-best-practice">
9-
<p class="admonition-title">Best Practice</p>
10-
<p>Use the bcrypt encoder for hashing your users' passwords.</p>
11-
</div>
7+
<div class="admonition admonition-best-practice ">
8+
<p class="admonition-title"> Best Practice </p>
9+
<p>Use the bcrypt encoder for hashing your users' passwords.</p>
1210
</div>
1311
</body>
1412
</html>

tests/fixtures/expected/blocks/directives/caution.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
<meta charset="utf-8" />
55
</head>
66
<body>
7-
<div class="admonition-wrapper">
8-
<div class="admonition admonition-caution">
9-
<p class="admonition-title">Caution</p>
10-
<p>Using too many sidebars or caution directives can be distracting!</p>
11-
</div>
7+
<div class="admonition admonition-caution ">
8+
<p class="admonition-title">
9+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor">
10+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
11+
</svg>
12+
Caution
13+
</p>
14+
<p>Using too many sidebars or caution directives can be distracting!</p>
1215
</div>
1316
</body>
1417
</html>

tests/fixtures/expected/blocks/directives/note-code-block-nested.html

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,30 @@
44
<meta charset="utf-8" />
55
</head>
66
<body>
7-
<div class="admonition-wrapper">
8-
<div class="admonition admonition-note">
9-
<p class="admonition-title">Note</p>
10-
<p>test</p>
11-
<div class="literal-block loc-1">
12-
<div class="highlight-php">
13-
<table class="highlighttable">
14-
<tr>
15-
<td class="linenos">
16-
<div class="linenodiv">
17-
<pre> 1</pre>
18-
</div>
19-
</td>
20-
<td class="code">
21-
<div class="highlight">
22-
<pre class="hljs php"><span class="hljs-comment">// code</span></pre>
23-
</div>
24-
</td>
25-
</tr>
26-
</table>
27-
</div>
7+
<div class="admonition admonition-note ">
8+
<p class="admonition-title">
9+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor">
10+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
11+
</svg>
12+
Note
13+
</p>
14+
<p>test</p>
15+
<div class="literal-block loc-1">
16+
<div class="highlight-php">
17+
<table class="highlighttable">
18+
<tr>
19+
<td class="linenos">
20+
<div class="linenodiv">
21+
<pre> 1</pre>
22+
</div>
23+
</td>
24+
<td class="code">
25+
<div class="highlight">
26+
<pre class="hljs php"><span class="hljs-comment">// code</span></pre>
27+
</div>
28+
</td>
29+
</tr>
30+
</table>
2831
</div>
2932
</div>
3033
</div>

tests/fixtures/expected/blocks/directives/note.html

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
<meta charset="utf-8" />
55
</head>
66
<body>
7-
<div class="admonition-wrapper">
8-
<div class="admonition admonition-note">
9-
<p class="admonition-title">Note</p>
10-
<p>Sometimes we add notes. But not too often because they interrupt the flow.</p>
11-
</div>
7+
<div class="admonition admonition-note ">
8+
<p class="admonition-title">
9+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor">
10+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
11+
</svg>
12+
Note
13+
</p>
14+
<p>Sometimes we add notes. But not too often because they interrupt the flow.</p>
1215
</div>
1316
</body>
1417
</html>

tests/fixtures/expected/blocks/directives/seealso.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
<meta charset="utf-8" />
55
</head>
66
<body>
7-
<div class="admonition-wrapper">
8-
<div class="admonition admonition-seealso">
9-
<p class="admonition-title">See also</p>
10-
<p>Also check out the homepage</p>
11-
</div>
7+
<div class="admonition admonition-seealso ">
8+
<p class="admonition-title"> See also </p>
9+
<p>Also check out the homepage</p>
1210
</div>
1311
</body>
14-
</html>
12+
</html>

tests/fixtures/expected/blocks/directives/tip.html

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
<meta charset="utf-8" />
55
</head>
66
<body>
7-
<div class="admonition-wrapper">
8-
<div class="admonition admonition-tip">
9-
<p class="admonition-title">Tip</p>
10-
<p>This is a little tip about something! We an also talk about specific</p>
11-
</div>
7+
<div class="admonition admonition-tip ">
8+
<p class="admonition-title">
9+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" width="24" height="24" viewBox="0 0 24 24" stroke="currentColor">
10+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z" />
11+
</svg>
12+
Tip
13+
</p>
14+
<p>This is a little tip about something! We an also talk about specific</p>
1215
</div>
1316
</body>
14-
</html>
17+
</html>

tests/fixtures/expected/build-pdf/book.html

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,35 @@
22
<head><title>book</title></head>
33
<body>
44
<div id="book-index">
5-
<div class="section" id="book-index-book">
6-
<h1>Book</h1>
5+
<div class="section">
6+
<h1 id="book-index-book"><a class="headerlink" href="#book" title="Permalink to this headline">Book</a></h1>
77
<img src="_images/symfony-logo.png">
8-
<p>Here is a link to the <em>main index</em><span
9-
class="footnote"><code>https://symfony.com/doc/4.0/index.html</code></span>
10-
</p>
8+
<p>Here is a link to the <a href="#index" class="reference internal">main index</a></p>
119
<div class="toctree-wrapper compound">
1210
<ul>
13-
<li><a href="#book-first-page-first-page">First page</a></li>
14-
<li><a href="#book-second-page-second-page">Second page</a></li>
11+
<li><a href="https://symfony.com/doc/4.0/book/first-page.html#first-page">First page</a></li>
12+
<li><a href="https://symfony.com/doc/4.0/book/second-page.html#second-page">Second page</a></li>
13+
1514
</ul>
1615
</div>
1716
</div>
1817

1918
</div>
2019
<div id="book-first-page">
21-
<div class="section" id="book-first-page-first-page">
22-
<h1>First page</h1>
20+
<div class="section">
21+
<h1 id="book-first-page-first-page">
22+
<a class="headerlink" href="#first-page" title="Permalink to this headline">First page</a>
23+
</h1>
24+
2325
</div>
2426

2527
</div>
2628
<div id="book-second-page">
27-
<div class="section" id="book-second-page-second-page">
28-
<h1>Second page</h1>
29+
<div class="section">
30+
<h1 id="book-second-page-second-page">
31+
<a class="headerlink" href="#second-page" title="Permalink to this headline">Second page</a>
32+
</h1>
33+
2934
</div>
3035

3136
</div>

0 commit comments

Comments
 (0)