mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
implement pango markup api
This commit is contained in:
parent
58bc99de06
commit
f81cf9fdee
5 changed files with 237 additions and 108 deletions
134
src/Abstract/Model/Gtk/Pango/Markup.php
Normal file
134
src/Abstract/Model/Gtk/Pango/Markup.php
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yggverse\Yoda\Abstract\Model\Gtk\Pango;
|
||||
|
||||
class Markup implements \Yggverse\Yoda\Interface\Model\Gtk\Pango\Markup
|
||||
{
|
||||
public static function code(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return sprintf(
|
||||
'<tt>%s</tt>',
|
||||
htmlspecialchars(
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function h1(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return sprintf(
|
||||
'<span size="xx-large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function h2(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return sprintf(
|
||||
'<span size="x-large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function h3(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return sprintf(
|
||||
'<span size="large">%s</span>',
|
||||
htmlspecialchars(
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function link(
|
||||
string $href,
|
||||
string $title,
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return sprintf(
|
||||
'<a href="%s" title="%s"><span underline="none">%s</span></a>',
|
||||
htmlspecialchars(
|
||||
$href
|
||||
),
|
||||
htmlspecialchars(
|
||||
$title
|
||||
),
|
||||
htmlspecialchars(
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function list(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return sprintf(
|
||||
'* %s', // @TODO
|
||||
htmlspecialchars(
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function quote(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return sprintf(
|
||||
'<i>%s</i>',
|
||||
htmlspecialchars(
|
||||
$value
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function text(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return htmlspecialchars(
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
public static function pre(
|
||||
string $value
|
||||
): string
|
||||
{
|
||||
return htmlspecialchars(
|
||||
$value
|
||||
);
|
||||
}
|
||||
|
||||
public static function tag(
|
||||
string $const,
|
||||
bool $close
|
||||
): string
|
||||
{
|
||||
if (in_array($const, [self::TAG_CODE]))
|
||||
{
|
||||
return sprintf(
|
||||
$close ? '</%s>' : '<%s>',
|
||||
$const
|
||||
);
|
||||
}
|
||||
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue