Browse Source

add document format filters

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

49
src/controller/room.php

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

Loading…
Cancel
Save