New lines in php transformed to
-
Hello everyone,
I am using LuckyWP Table of Contents and Bricks Builder as page builder.
Somehow when I am using the plugin, there are too many line breaks in the HTML code. It looks like this:But it should look like this:
I went through the plugin and I think I found the issue.
The file luckywp-table-of-contents/front/views/items.php seems to be the issue. The file looks like this:<?php
/**
* @var $items array
* @var $depth int
* @var $containerTag string
* @var $itemTag string
*/
use luckywp\tableOfContents\core\helpers\Html;
echo Html::beginTag($containerTag, ['class' => 'lwptoc_itemWrap']);
foreach ($items as $item) {
echo Html::beginTag($itemTag, ['class' => 'lwptoc_item']);
?>
<a href="#<?php echo $item['id'] ?>"<?php echo $item['relNofollow'] ?>>
<?php if ($item['number']) { ?>
<span class="lwptoc_item_number"><?php echo $item['number'] . $item['numberSuffix'] ?></span>
<?php } ?>
<span class="lwptoc_item_label"><?php echo esc_html($item['label']) ?></span>
</a>
<?php
lwptoc_items($item['childrens']);
echo Html::endTag($itemTag);
}
echo Html::endTag($containerTag);And somehow the new lines in line 15 to 20 are translated to
<br>
when rendering the HTML.
When I remove the new lines in the file as shown here, it works, no additional<br>
are created:<?php
/**
* @var $items array
* @var $depth int
* @var $containerTag string
* @var $itemTag string
*/
use luckywp\tableOfContents\core\helpers\Html;
echo Html::beginTag($containerTag, ['class' => 'lwptoc_itemWrap']);
foreach ($items as $item) {
echo Html::beginTag($itemTag, ['class' => 'lwptoc_item']);
?>
<a href="#<?php echo $item['id'] ?>"<?php echo $item['relNofollow'] ?>><?php
if ($item['number']) {
?><span class="lwptoc_item_number"><?php echo $item['number'] . $item['numberSuffix'] ?> </span><?php
} ?><span class="lwptoc_item_label"><?php echo esc_html($item['label']) ?></span>
</a>
<?php
lwptoc_items($item['childrens']);
echo Html::endTag($itemTag);
}
echo Html::endTag($containerTag);I already posted that in the Bricks community, the answer there was, that “when you have PHP tags () with HTML in between, any whitespace (including newlines) between them gets rendered as-is in the output HTML”.
So for me it seems like this is a bug or incompatibility in the LuckyWP TOC.Cany someone take a look into this? Any help is appreciated.
Thank you and best regards
The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.