phpDocumentor / guides

Guides library to parse documentation
MIT License
31 stars 15 forks source link

Text roles and whitespace control #305

Closed wouterj closed 1 year ago

wouterj commented 1 year ago

Contrary to body elements, preserving original whitespace is important for inline elements.

Some tests on the Symfony test repository are failing because of missing spaces before an inline <code> element, as well as new lines after a </code> tag. (EDIT: missing space before is probably due to a bit too heavy whitespace removal by the tests)

An inline newline is converted to a space in HTML, which works out most of the time but not when e.g. you put an inline literal before a final stop or comma (like at the end of the test case below).

See e.g. this test output:


3) SymfonyDocsBuilder\Tests\HtmlIntegrationTest::testBlocks with data set "text-roles/reference-and-code.rst" ('/home/runner/work/symfony-doc...de.rst', '/home/runner/work/symfony-doc...e.html')
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'<p>Next, create the template used to render the field in the<code translate="no" class="notranslate">index</code>and<code translate="no" class="notranslate">detail</code>\n
-<a href="https://symfony.com/doc/current/bundles/EasyAdminBundle/crud.html" class="reference internal">CRUD pages</a>.</p>\n
+'<p>Next, create the template used to render the field in the<code translate="no" class="notranslate">index</code>\n
+and<code translate="no" class="notranslate">detail</code><a href="https://symfony.com/doc/current/bundles/EasyAdminBundle/crud.html" class="reference internal">CRUD pages</a>\n
+.</p>\n
 <p>More about CRUD pages.</p>'

/home/runner/work/symfony-docs-guides/symfony-docs-guides/lib/docs-builder/tests/integration/HtmlIntegrationTest.php:29```
linawolf commented 1 year ago

@wouterj what was exactly was your input? Could you move your test into this repository

wouterj commented 1 year ago

Good call, see this branch for a failing test case: https://github.com/phpDocumentor/guides/compare/main...wouterj:guides:issue-305

It also seems to indicate that this does work as expected for emphasis, but not for inline literals.

linawolf commented 1 year ago

I cherry picked your tests into #385, some of the issues had already been resolved, I resolved one more issues: templates in inline code caused unwanted newlines.