-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EZP-31028: Fixed formatting involving soft return placed inside a Cus…
…tom Template (#78)
- Loading branch information
Showing
15 changed files
with
340 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\Tests\EzPlatformRichText\eZ\RichText\Converter\Xslt; | ||
|
||
use EzSystems\EzPlatformRichText\eZ\RichText\RendererInterface; | ||
|
||
final class DebugRenderer implements RendererInterface | ||
{ | ||
private const TEMPLATE_FORMAT = '<template-output name="%s" type="%s" is-inline="%s">%s</template-output>'; | ||
private const EMBED_CONTENT_FORMAT = '<embed-content-output content-id="%d" view-type="%s" is-inline="%s">%s</embed-content-output>'; | ||
private const EMBED_LOCATION_FORMAT = '<embed-location-output location-id="%d" view-type="%s" is-inline="%s">%s</embed-location-output>'; | ||
|
||
public function renderTag($name, array $parameters, $isInline): string | ||
{ | ||
return $this->renderTemplate($name, 'tag', $parameters, $isInline); | ||
} | ||
|
||
public function renderTemplate($name, $type, array $parameters, $isInline): string | ||
{ | ||
return sprintf( | ||
self::TEMPLATE_FORMAT, | ||
$name, | ||
$type, | ||
$this->serializeIsInline($isInline), | ||
$this->serializeParameters($parameters) | ||
); | ||
} | ||
|
||
public function renderContentEmbed($contentId, $viewType, array $parameters, $isInline): string | ||
{ | ||
return sprintf( | ||
self::EMBED_CONTENT_FORMAT, | ||
$contentId, | ||
$viewType, | ||
$this->serializeIsInline($isInline), | ||
$this->serializeParameters($parameters) | ||
); | ||
} | ||
|
||
public function renderLocationEmbed($locationId, $viewType, array $parameters, $isInline): string | ||
{ | ||
return sprintf( | ||
self::EMBED_LOCATION_FORMAT, | ||
$locationId, | ||
$viewType, | ||
$this->serializeIsInline($isInline), | ||
$this->serializeParameters($parameters) | ||
); | ||
} | ||
|
||
private function serializeParameters(array $parameters): string | ||
{ | ||
$lines = []; | ||
|
||
foreach ($parameters as $name => $value) { | ||
if (is_array($value)) { | ||
if (!empty($value)) { | ||
$lines[] = sprintf('<param name="%s">', $name); | ||
$lines[] = $this->serializeParameters($value); | ||
$lines[] = sprintf('</param>'); | ||
} | ||
} else { | ||
$lines[] = sprintf('<param name="%s">%s</param>', $name, $value); | ||
} | ||
} | ||
|
||
return implode('', $lines); | ||
} | ||
|
||
private function serializeIsInline(bool $isInline): string | ||
{ | ||
return $isInline ? 'true' : 'false'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 56 additions & 2 deletions
58
tests/lib/eZ/RichText/Converter/Xslt/_fixtures/xhtml5/output/024-template.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5"/> | ||
<?xml version="1.0"?> | ||
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5"> | ||
<template-output is-inline="false" name="factbox" type="tag"> | ||
<param name="name">factbox</param> | ||
<param name="params"> | ||
<param name="title">Factoids</param> | ||
</param> | ||
<param name="content"> | ||
<section> | ||
<table title="tableTitle"> | ||
<caption>About factoids</caption> | ||
<tbody> | ||
<tr> | ||
<th> | ||
<h3 style="text-align:center;">Some facts about factoids</h3> | ||
</th> | ||
</tr> | ||
<tr> | ||
<td> | ||
<p>A factoid is a questionable or spurious (unverified, false, or fabricated) statement presented as a fact, but without supporting evidence.</p> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td> | ||
<p>Factoids may give rise to, or arise from, common misconceptions and urban legends.</p> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</section> | ||
</param> | ||
<param name="align">left</param> | ||
</template-output> | ||
<template-output is-inline="false" name="externalimage" type="tag"> | ||
<param name="name">externalimage</param> | ||
<param name="params"> | ||
<param name="src">http://upload.wikimedia.org/wikipedia/commons/c/c6/R-S_mk2.gif</param> | ||
<param name="height">365</param> | ||
<param name="width">500</param> | ||
<param name="alt">flip-flop</param> | ||
<param name="caption">bistable multivibrator</param> | ||
</param> | ||
<param name="align">right</param> | ||
</template-output> | ||
<template-output is-inline="false" name="factoidbox" type="tag"> | ||
<param name="name">factoidbox</param> | ||
<param name="content"> | ||
<section>It is widely known that the bistable multivibrator hums z's in the middle octave key of E.</section> | ||
</param> | ||
<param name="align">center</param> | ||
</template-output> | ||
<template-output is-inline="false" name="factoidbox" type="tag"> | ||
<param name="name">factoidbox</param> | ||
<param name="align">center</param> | ||
</template-output> | ||
</section> |
10 changes: 5 additions & 5 deletions
10
tests/lib/eZ/RichText/Converter/Xslt/_fixtures/xhtml5/output/025-templateInline.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml version="1.0"?> | ||
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5"> | ||
<p>Some for the otherwise unremarkable paragraph.</p> | ||
<p>This paragraph is just showing off its .</p> | ||
<p>The equation ties together five of the most important mathematical constants.</p> | ||
<p>This paragraph contains some .</p> | ||
<p>Some <template-output is-inline="true" name="emojicake" type="tag"><param name="name">emojicake</param></template-output> for the otherwise unremarkable paragraph.</p> | ||
<p>This paragraph is just showing off its <template-output is-inline="true" name="emojicrocodile" type="tag"><param name="name">emojicrocodile</param><param name="params"><param name="size">large</param></param></template-output>.</p> | ||
<p>The equation <template-output is-inline="true" name="tex" type="tag"><param name="name">tex</param><param name="params"><param name="color">red</param></param><param name="content"><section>e^{\pi i}+1=0</section></param></template-output> ties together five of the most important mathematical constants.</p> | ||
<p>This paragraph contains some <template-output is-inline="true" name="bold" type="tag"><param name="name">bold</param><param name="content"><section>styled <template-output is-inline="true" name="strikedthrough" type="tag"><param name="name">strikedthrough</param><param name="content"><section>text</section></param></template-output></section></param></template-output>.</p> | ||
</section> |
38 changes: 36 additions & 2 deletions
38
tests/lib/eZ/RichText/Converter/Xslt/_fixtures/xhtml5/output/031-ezstyle.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5"/> | ||
<?xml version="1.0"?> | ||
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5"> | ||
<template-output is-inline="false" name="highlighted_block" type="style"> | ||
<param name="name">highlighted_block</param> | ||
<param name="content"> | ||
<section>Highlighted block with "left" align.</section> | ||
</param> | ||
<param name="align">left</param> | ||
</template-output> | ||
<template-output is-inline="false" name="highlighted_block" type="style"> | ||
<param name="name">highlighted_block</param> | ||
<param name="content"> | ||
<section>Highlighted block with "right" align.</section> | ||
</param> | ||
<param name="align">right</param> | ||
</template-output> | ||
<template-output is-inline="false" name="highlighted_block" type="style"> | ||
<param name="name">highlighted_block</param> | ||
<param name="content"> | ||
<section>Highlighted block with "center" align.</section> | ||
</param> | ||
<param name="align">center</param> | ||
</template-output> | ||
<template-output is-inline="false" name="highlighted_block" type="style"> | ||
<param name="name">highlighted_block</param> | ||
<param name="content"> | ||
<section>Highlighted block with multiple lines<br/>Highlighted block with multiple lines<br/>Highlighted block with multiple lines</section> | ||
</param> | ||
</template-output> | ||
<template-output is-inline="false" name="highlighted_block" type="style"> | ||
<param name="name">highlighted_block</param> | ||
<param name="content"> | ||
<section>Highlighted block with multiple lines and emphasis<br/><strong>Highlighted block with multiple lines and emphasis</strong><br/>Highlighted block with multiple lines and emphasis</section> | ||
</param> | ||
</template-output> | ||
</section> |
4 changes: 2 additions & 2 deletions
4
tests/lib/eZ/RichText/Converter/Xslt/_fixtures/xhtml5/output/032-ezstyleinline.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml version="1.0"?> | ||
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5"> | ||
<p>Some for the otherwise unremarkable paragraph.</p> | ||
<p>Some <template-output is-inline="true" name="highlighted_word" type="style"><param name="name">highlighted_word</param><param name="content"><section>highlighted words<br/>with line break</section></param></template-output> for the otherwise unremarkable paragraph.</p> | ||
</section> |
29 changes: 27 additions & 2 deletions
29
tests/lib/eZ/RichText/Converter/Xslt/_fixtures/xhtml5/output/034-nestedTemplate.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5" /> | ||
<?xml version="1.0"?> | ||
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5"> | ||
<template-output is-inline="false" name="factbox" type="tag"> | ||
<param name="name">factbox</param> | ||
<param name="params"> | ||
<param name="title">Factoids</param> | ||
</param> | ||
<param name="content"> | ||
<section> | ||
<template-output is-inline="false" name="externalimage" type="tag"> | ||
<param name="name">externalimage</param> | ||
<param name="params"> | ||
<param name="src"> | ||
http://upload.wikimedia.org/wikipedia/commons/c/c6/R-S_mk2.gif | ||
</param> | ||
<param name="height">365</param> | ||
<param name="width">500</param> | ||
<param name="alt">flip-flop</param> | ||
<param name="caption">bistable multivibrator</param> | ||
</param> | ||
<param name="align">right</param> | ||
</template-output> | ||
</section> | ||
</param> | ||
<param name="align">left</param> | ||
</template-output> | ||
</section> |
Oops, something went wrong.