mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-02 17:45:28 +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
|
// Dependencies
|
||||||
public \Yggverse\Yoda\Entity\Browser\Container\Page\Content $content;
|
public \Yggverse\Yoda\Entity\Browser\Container\Page\Content $content;
|
||||||
|
|
||||||
|
// Defaults
|
||||||
|
private int $_wrap = 140;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
\Yggverse\Yoda\Entity\Browser\Container\Page\Content $content
|
\Yggverse\Yoda\Entity\Browser\Container\Page\Content $content
|
||||||
) {
|
) {
|
||||||
|
|
@ -31,19 +34,10 @@ class Data
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->gtk->set_line_wrap(
|
|
||||||
true
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->gtk->set_can_focus(
|
$this->gtk->set_can_focus(
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
/* @TODO pending for PR #120
|
|
||||||
$this->gtk->set_line_wrap_mode(
|
|
||||||
\PangoWrapMode::WORD
|
|
||||||
);*/
|
|
||||||
|
|
||||||
$this->gtk->set_track_visited_links(
|
$this->gtk->set_track_visited_links(
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
@ -146,8 +140,10 @@ class Data
|
||||||
$line[] = sprintf(
|
$line[] = sprintf(
|
||||||
'<span size="xx-large">%s</span>',
|
'<span size="xx-large">%s</span>',
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
|
$this->_wrap(
|
||||||
$entity->getText()
|
$entity->getText()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Find and return document title by first # tag
|
// Find and return document title by first # tag
|
||||||
|
|
@ -163,8 +159,10 @@ class Data
|
||||||
$line[] = sprintf(
|
$line[] = sprintf(
|
||||||
'<span size="x-large">%s</span>',
|
'<span size="x-large">%s</span>',
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
|
$this->_wrap(
|
||||||
$entity->getText()
|
$entity->getText()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -174,8 +172,10 @@ class Data
|
||||||
$line[] = sprintf(
|
$line[] = sprintf(
|
||||||
'<span size="large">%s</span>',
|
'<span size="large">%s</span>',
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
|
$this->_wrap(
|
||||||
$entity->getText()
|
$entity->getText()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -197,9 +197,11 @@ class Data
|
||||||
$entity->getAddress()
|
$entity->getAddress()
|
||||||
),
|
),
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
|
$this->_wrap(
|
||||||
$entity->getAlt() ? $entity->getAlt()
|
$entity->getAlt() ? $entity->getAlt()
|
||||||
: $entity->getAddress() // @TODO date
|
: $entity->getAddress() // @TODO date
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -209,8 +211,10 @@ class Data
|
||||||
$line[] = sprintf(
|
$line[] = sprintf(
|
||||||
'* %s',
|
'* %s',
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
|
$this->_wrap(
|
||||||
$entity->getItem()
|
$entity->getItem()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -220,8 +224,10 @@ class Data
|
||||||
$line[] = sprintf(
|
$line[] = sprintf(
|
||||||
'<i>%s</i>',
|
'<i>%s</i>',
|
||||||
htmlspecialchars(
|
htmlspecialchars(
|
||||||
|
$this->_wrap(
|
||||||
$entity->getText()
|
$entity->getText()
|
||||||
)
|
)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -229,7 +235,9 @@ class Data
|
||||||
case $entity instanceof \Yggverse\Gemtext\Entity\Text:
|
case $entity instanceof \Yggverse\Gemtext\Entity\Text:
|
||||||
|
|
||||||
$line[] = htmlspecialchars(
|
$line[] = htmlspecialchars(
|
||||||
|
$this->_wrap(
|
||||||
$entity->getData()
|
$entity->getData()
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -248,6 +256,18 @@ class Data
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function _wrap(
|
||||||
|
string $value
|
||||||
|
): string
|
||||||
|
{
|
||||||
|
return wordwrap(
|
||||||
|
$value,
|
||||||
|
$this->_wrap,
|
||||||
|
PHP_EOL,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private function _url(
|
private function _url(
|
||||||
string $link
|
string $link
|
||||||
): ?string
|
): ?string
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue