Skip to content

[WIP] Fix missing line break with anchors #80

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

Merged
merged 4 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Templates/default/html/paragraph.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% set text = paragraphNode.value.render()|trim %}

{%- if text %}
<p{% if paragraphNode.classes %} class="{{ paragraphNode.classesString }}"{% endif %}>{{ text|raw }}</p>
{% endif %}
2 changes: 1 addition & 1 deletion tests/AbstractIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Symfony\Component\Filesystem\Filesystem;
use SymfonyDocsBuilder\BuildConfig;

class AbstractIntegrationTest extends TestCase
abstract class AbstractIntegrationTest extends TestCase
{
protected function createBuildConfig(string $sourceDir): BuildConfig
{
Expand Down
14 changes: 10 additions & 4 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ public function testParseUnitBlock(string $blockName)

$sourceFile = sprintf('%s/fixtures/source/blocks/%s.rst', __DIR__, $blockName);

$document = $parser->parseFile($sourceFile)->renderDocument();
$actualHtml = $parser->parseFile($sourceFile)->renderDocument();
$expectedHtml = file_get_contents(sprintf('%s/fixtures/expected/blocks/%s.html', __DIR__, $blockName));

$actualCrawler = new Crawler($actualHtml);
$expectedCrawler = new Crawler($expectedHtml);
$indenter = $this->createIndenter();

$expectedFile = sprintf('%s/fixtures/expected/blocks/%s.html', __DIR__, $blockName);
$this->assertSame(
str_replace(" \n", "\n", $indenter->indent(file_get_contents($expectedFile))),
str_replace(" \n", "\n", $indenter->indent($document))
$indenter->indent(trim($expectedCrawler->filter('body')->html())),
$indenter->indent(trim($actualCrawler->filter('body')->html()))
);
}

Expand Down Expand Up @@ -197,6 +199,10 @@ public function parserUnitBlockProvider()
'blockName' => 'references/php-method',
];

yield 'reference-and-code' => [
'blockName' => 'references/reference-and-code',
];

yield 'code-block-php' => [
'blockName' => 'code-blocks/php',
];
Expand Down
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/bash.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-bash">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-bash">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1</pre>
<pre class="codeblock-code"><code>git <span class="hljs-built_in">clone</span> git@github.com:symfony/symfony.git
</code></pre>
</div>
</div>

</body>
</html>
15 changes: 1 addition & 14 deletions tests/fixtures/expected/blocks/code-blocks/html-php.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-2 codeblock-html+php codeblock-html">
<div translate="no" class="notranslate codeblock codeblock-loc-2 codeblock-html+php codeblock-html">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1
2
Expand Down Expand Up @@ -35,7 +26,3 @@
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/html-twig.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-html+twig codeblock-twig">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-html+twig codeblock-twig">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1
2</pre>
Expand All @@ -16,6 +7,3 @@
</span></code></pre>
</div>
</div>

</body>
</html>
15 changes: 1 addition & 14 deletions tests/fixtures/expected/blocks/code-blocks/html.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-html">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-html">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1</pre>
<pre class="codeblock-code"><code><span class="hljs-comment">&lt;!-- some code --&gt;</span>
</code></pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/ini.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-ini">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-ini">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1</pre>
<pre class="codeblock-code"><code><span class="hljs-attr">fetch</span> = +refs/notes/*:refs/notes/*
</code></pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/php-annotations.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-2 codeblock-php-annotations codeblock-php">
<div translate="no" class="notranslate codeblock codeblock-loc-2 codeblock-php-annotations codeblock-php">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1
2
Expand Down Expand Up @@ -40,6 +31,3 @@
</code></pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/php.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-php">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-php">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1
2
Expand All @@ -26,6 +17,3 @@
</code></pre>
</div>
</div>

</body>
</html>
18 changes: 3 additions & 15 deletions tests/fixtures/expected/blocks/code-blocks/terminal.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-terminal codeblock-bash">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-terminal codeblock-bash">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1</pre>
<pre class="codeblock-code"><code>git <span class="hljs-built_in">clone</span> git@github.com:symfony/symfony.git
<pre class="codeblock-code"><code>git <span
class="hljs-built_in">clone</span> git@github.com:symfony/symfony.git
</code></pre>
</div>
</div>

<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-terminal codeblock-bash">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1
Expand Down Expand Up @@ -43,6 +34,3 @@
</pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/text.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-text">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-text">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1</pre>
<pre class="codeblock-code"><code>some text
</code></pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/twig.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-twig">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-twig">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1</pre>
<pre class="codeblock-code"><code><span class="hljs-comment">{# some code #}</span><span class="xml">
</span></code></pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/xml.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-xml">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-xml">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1</pre>
<pre class="codeblock-code"><code><span class="hljs-comment">&lt;!-- some code --&gt;</span>
</code></pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/code-blocks/yaml.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-yaml">
<div translate="no" class="notranslate codeblock codeblock-loc-1 codeblock-yaml">
<div class="codeblock-scroll">
<pre class="codeblock-lines">1</pre>
<pre class="codeblock-code"><code><span class="hljs-comment"># some code</span>
</code></pre>
</div>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/directives/admonition.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div class="admonition admonition-default screencast_class">
<div class="admonition admonition-default screencast_class">
<p class="admonition-title">
Screencast
</p><p>Do you prefer video tutorials? Check out the the screencasts.</p>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/directives/best-practice.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div class="admonition admonition-best-practice ">
<div class="admonition admonition-best-practice ">
<p class="admonition-title">
Best Practice
</p><p>Use the bcrypt encoder for hashing your users' passwords.</p>
</div>

</body>
</html>
14 changes: 1 addition & 13 deletions tests/fixtures/expected/blocks/directives/caution.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />


</head>

<body>
<div class="admonition admonition-caution ">
<div class="admonition admonition-caution ">
<p class="admonition-title">
<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="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" /></svg>
Caution
</p><p>Using too many sidebars or caution directives can be distracting!</p>
</div>

</body>
</html>
Loading