mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-20 03:35:13 +00:00
provide activitypub rendering of inline svg doodles
This commit is contained in:
parent
3b2eabf0fd
commit
2695bded8f
1 changed files with 23 additions and 1 deletions
|
@ -299,6 +299,23 @@ function bb_svg($match) {
|
|||
return $output;
|
||||
}
|
||||
|
||||
function bb_svg_export($match) {
|
||||
|
||||
$params = str_replace(['<br>', '"'], [ '', '"'],$match[1]);
|
||||
$Text = str_replace([ '[',']' ], [ '<','>' ], $match[2]);
|
||||
|
||||
$output = '<svg' . (($params) ? $params : ' width="100%" height="480" ') . '>' . str_replace(['<br>', '"', ' '], [ '', '"', ' '],$Text) . '</svg>';
|
||||
|
||||
$purify = new SvgSanitizer();
|
||||
$purify->loadXML($output);
|
||||
$purify->sanitize();
|
||||
$output = $purify->saveSVG();
|
||||
$output = preg_replace("/\<\?xml(.*?)\?\>/",'',$output);
|
||||
$output = '<img alt="svg" src="data:image/svg+xml,' . urlencode($output) . '" >';
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
function bb_parse_element($match) {
|
||||
$j = json_decode(base64url_decode($match[1]),true);
|
||||
|
||||
|
@ -1567,8 +1584,13 @@ function bbcode($Text, $options = []) {
|
|||
}
|
||||
|
||||
// SVG stuff
|
||||
$Text = preg_replace_callback("/\[svg(.*?)\](.*?)\[\/svg\]/ism", 'bb_svg', $Text);
|
||||
|
||||
if ($activitypub) {
|
||||
$Text = preg_replace_callback("/\[svg(.*?)\](.*?)\[\/svg\]/ism", 'bb_svg_export', $Text);
|
||||
}
|
||||
else {
|
||||
$Text = preg_replace_callback("/\[svg(.*?)\](.*?)\[\/svg\]/ism", 'bb_svg', $Text);
|
||||
}
|
||||
|
||||
// oembed tag
|
||||
if(! $export)
|
||||
|
|
Loading…
Reference in a new issue