Browse Source

add document format filters

main
ghost 10 months ago
parent
commit
537706f39c
  1. 43
      src/controller/room.php
  2. 2
      src/view/post.gemini

43
src/controller/room.php

@ -256,13 +256,22 @@ class Room @@ -256,13 +256,22 @@ class Room
if ($post['txid'] == $quote)
{
// Strip folding
$quote =
$quote = '>' .
trim(
preg_replace(
'/^@([A-z0-9]{64})/',
null,
// Add quote after each new line
str_replace(
PHP_EOL,
PHP_EOL . '>',
// Ignore markup
$this->_plain(
$post['value']
)
)
),
'>'
);
break;
@ -270,7 +279,13 @@ class Room @@ -270,7 +279,13 @@ class Room
}
// Remove mention from message
$record['value'] = preg_replace('/^@([A-z0-9]{64})/', null, $record['value']);
$record['value'] = preg_replace(
'/^@([A-z0-9]{64})/',
null,
$this->_plain(
$record['value']
)
);
}
}
@ -292,10 +307,9 @@ class Room @@ -292,10 +307,9 @@ class Room
$matches[1]
),
'@' . $matches[2],
trim(
$quote
),
trim(
,
$this->_plain(
$record['value']
)
],
@ -380,4 +394,23 @@ class Room @@ -380,4 +394,23 @@ class Room
return $texts[(($number % 100) > 4 && ($number % 100) < 20) ? 2 : $cases[min($number % 10, 5)]];
}
private function _plain(string $value)
{
return trim(
str_replace(
[
'#',
'##',
'###',
'>',
'*',
'```',
'=>',
],
null,
$value
)
);
}
}

2
src/view/post.gemini

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
## {author}
> {quote}
{quote}
{message}
```
{time} #{txid}

Loading…
Cancel
Save