Browse Source

fix new lines format

main
ghost 10 months ago
parent
commit
46fefa0e90
  1. 32
      src/controller/room.php
  2. 2
      src/view/post.gemini

32
src/controller/room.php

@ -261,17 +261,21 @@ class Room
$quote = '>' . $quote = '>' .
trim( trim(
preg_replace( preg_replace(
'/^@([A-z0-9]{64})/', '/^@([A-z0-9]{64}[\n\r]?)/',
null, null,
// Add quote after each new line // Add quote after each new line
str_replace( str_replace(
PHP_EOL, PHP_EOL,
PHP_EOL . '>', PHP_EOL . '>',
preg_replace(
'/[\n\r]+/',
PHP_EOL,
// Ignore markup // Ignore markup
$this->_plain( $this->_plain(
$post['value'] $post['value']
) )
) )
)
), ),
'>' '>'
); );
@ -284,9 +288,13 @@ class Room
$record['value'] = preg_replace( $record['value'] = preg_replace(
'/^@([A-z0-9]{64})/', '/^@([A-z0-9]{64})/',
null, null,
preg_replace(
'/[\n\r]+/',
PHP_EOL,
$this->_plain( $this->_plain(
$record['value'] $record['value']
) )
)
); );
} }
} }
@ -302,8 +310,7 @@ class Room
'{author}', '{author}',
'{quote}', '{quote}',
'{message}', '{message}',
'{reply}', '{reply}'
PHP_EOL . PHP_EOL
], ],
[ [
$record['txid'], $record['txid'],
@ -312,8 +319,12 @@ class Room
), ),
'@' . $matches[2], '@' . $matches[2],
$quote, $quote,
preg_replace(
'/[\n\r]+/',
PHP_EOL,
$this->_plain( $this->_plain(
$record['value'] $record['value']
)
), ),
$this->_url( // @TODO $this->_url( // @TODO
sprintf( sprintf(
@ -321,8 +332,7 @@ class Room
$namespace, $namespace,
$record['txid'], $record['txid'],
) )
), )
PHP_EOL
], ],
file_get_contents( file_get_contents(
__DIR__ . '/../view/post.gemini' __DIR__ . '/../view/post.gemini'
@ -414,12 +424,20 @@ class Room
'#', '#',
'##', '##',
'###', '###',
'=>',
'>', '>',
'*', '*',
'```', '```'
],
[
' #',
' ##',
' ###',
' =>', ' =>',
' >',
' *',
' ```'
], ],
null,
$value $value
) )
); );

2
src/view/post.gemini

@ -1,7 +1,5 @@
### {author} [{time}] ### {author} [{time}]
{quote} {quote}
{message} {message}
=> {reply} Reply => {reply} Reply

Loading…
Cancel
Save