mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
use php line wrap method
This commit is contained in:
parent
d3f21929ea
commit
21575345a0
1 changed files with 37 additions and 17 deletions
|
|
@ -14,6 +14,9 @@ class Data
|
|||
// Dependencies
|
||||
public \Yggverse\Yoda\Entity\Browser\Container\Page\Content $content;
|
||||
|
||||
// Defaults
|
||||
private int $_wrap = 140;
|
||||
|
||||
public function __construct(
|
||||
\Yggverse\Yoda\Entity\Browser\Container\Page\Content $content
|
||||
) {
|
||||
|
|
@ -31,19 +34,10 @@ class Data
|
|||
true
|
||||
);
|
||||
|
||||
$this->gtk->set_line_wrap(
|
||||
true
|
||||
);
|
||||
|
||||
$this->gtk->set_can_focus(
|
||||
false
|
||||
);
|
||||
|
||||
/* @TODO pending for PR #120
|
||||
$this->gtk->set_line_wrap_mode(
|
||||
\PangoWrapMode::WORD
|
||||
);*/
|
||||
|
||||
$this->gtk->set_track_visited_links(
|
||||
true
|
||||
);
|
||||
|
|
@ -146,7 +140,9 @@ class Data
|
|||
$line[] = sprintf(
|
||||
'<span size="xx-large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$entity->getText()
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -163,7 +159,9 @@ class Data
|
|||
$line[] = sprintf(
|
||||
'<span size="x-large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$entity->getText()
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -174,7 +172,9 @@ class Data
|
|||
$line[] = sprintf(
|
||||
'<span size="large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$entity->getText()
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -197,8 +197,10 @@ class Data
|
|||
$entity->getAddress()
|
||||
),
|
||||
htmlspecialchars(
|
||||
$entity->getAlt() ? $entity->getAlt()
|
||||
: $entity->getAddress() // @TODO date
|
||||
$this->_wrap(
|
||||
$entity->getAlt() ? $entity->getAlt()
|
||||
: $entity->getAddress() // @TODO date
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -209,7 +211,9 @@ class Data
|
|||
$line[] = sprintf(
|
||||
'* %s',
|
||||
htmlspecialchars(
|
||||
$entity->getItem()
|
||||
$this->_wrap(
|
||||
$entity->getItem()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -220,7 +224,9 @@ class Data
|
|||
$line[] = sprintf(
|
||||
'<i>%s</i>',
|
||||
htmlspecialchars(
|
||||
$entity->getText()
|
||||
$this->_wrap(
|
||||
$entity->getText()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -229,7 +235,9 @@ class Data
|
|||
case $entity instanceof \Yggverse\Gemtext\Entity\Text:
|
||||
|
||||
$line[] = htmlspecialchars(
|
||||
$entity->getData()
|
||||
$this->_wrap(
|
||||
$entity->getData()
|
||||
)
|
||||
);
|
||||
|
||||
break;
|
||||
|
|
@ -248,6 +256,18 @@ class Data
|
|||
);
|
||||
}
|
||||
|
||||
private function _wrap(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return wordwrap(
|
||||
$value,
|
||||
$this->_wrap,
|
||||
PHP_EOL,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
private function _url(
|
||||
string $link
|
||||
): ?string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue