diff --git a/src/Renderers/SpanNodeRenderer.php b/src/Renderers/SpanNodeRenderer.php index 2268b6b..0fc9f9c 100644 --- a/src/Renderers/SpanNodeRenderer.php +++ b/src/Renderers/SpanNodeRenderer.php @@ -62,7 +62,21 @@ public function link(?string $url, string $title, array $attributes = []): strin ); } - public function isExternalUrl($url): bool + public function literal(string $text): string + { + // some browsers can't break long properly, so we inject a + // `` (word-break HTML tag) after some characters to help break those + // We only do this for very long (4 or more \\) to not break short + // and common `` such as App\Entity\Something + if (substr_count($text, '\\') >= 4) { + // breaking before the backslask is what Firefox browser does + $text = str_replace('\\', '\\', $text); + } + + return $this->templateRenderer->render('literal.html.twig', ['text' => $text]); + } + + private function isExternalUrl($url): bool { return u($url)->containsAny('://'); } diff --git a/tests/fixtures/expected/blocks/nodes/literal.html b/tests/fixtures/expected/blocks/nodes/literal.html index d85a683..f0eaec8 100644 --- a/tests/fixtures/expected/blocks/nodes/literal.html +++ b/tests/fixtures/expected/blocks/nodes/literal.html @@ -28,5 +28,13 @@ +

+ The CRUD controller of App\Entity\Example must implement +the + EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\CrudControllerInterface + , +but you can also extend from the AbstractCrudController class. +

+ - \ No newline at end of file + diff --git a/tests/fixtures/expected/main/datetime.html b/tests/fixtures/expected/main/datetime.html index d250b1a..41a6b1e 100644 --- a/tests/fixtures/expected/main/datetime.html +++ b/tests/fixtures/expected/main/datetime.html @@ -126,7 +126,7 @@

format

-

type: stringdefault: Symfony\Component\Form\Extension\Core\Type\DateTimeType::HTML5_FORMAT

+

type: stringdefault: Symfony\Component\Form\Extension\Core\Type\DateTimeType::HTML5_FORMAT

If the widget option is set to single_text, this option specifies the format of the input, i.e. how Symfony will interpret the given input as a datetime string. See Date/Time Format Syntax.

@@ -317,4 +317,4 @@

- \ No newline at end of file + diff --git a/tests/fixtures/source/blocks/nodes/literal.rst b/tests/fixtures/source/blocks/nodes/literal.rst index 6521364..43e6570 100644 --- a/tests/fixtures/source/blocks/nodes/literal.rst +++ b/tests/fixtures/source/blocks/nodes/literal.rst @@ -1,4 +1,3 @@ - here is some php code from literal:: // config/routes.php @@ -9,3 +8,6 @@ here is some php code from literal:: ->controller('App\Controller\CompanyController::about'); }; +The CRUD controller of ``App\Entity\Example`` must implement +the ``EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\CrudControllerInterface``, +but you can also extend from the ``AbstractCrudController`` class.