Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fe350ef

Browse files
:octocat: eol handling
1 parent e846663 commit fe350ef

File tree

5 files changed

+28
-1
lines changed

5 files changed

+28
-1
lines changed

‎src/BBCode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ public function parse(string $bbcode):string{
197197
}
198198

199199
// replace the newline placeholders
200-
$bbcode = str_replace($this->options->placeholder_eol, PHP_EOL, $bbcode);
200+
$bbcode = str_replace($this->options->placeholder_eol, $this->outputInterface->getEOL(), $bbcode);
201201

202202
// run the sanitizer/html purifier/whatever as a final step
203203
if($this->options->sanitizeOutput){

‎src/BBCodeOptions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
* @property int $pcre_recursion_limit
2828
* @property int $pcre_jit
2929
* @property string $placeholder_eol
30+
* @property string $replacement_eol
3031
* @property string $placeholder_bbtag
3132
* @property array $allowedTags
3233
* @property bool $allowAvailableTags

‎src/BBCodeOptionsTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ trait BBCodeOptionsTrait{
101101
*/
102102
protected $placeholder_eol = '{EOL}';
103103

104+
/**
105+
* optional EOL replacement
106+
*
107+
* @var string
108+
*/
109+
protected $replacement_eol = null;
110+
104111
/**
105112
* The key name of the tag attribute
106113
*

‎src/Output/BBCodeOutputAbstract.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ abstract class BBCodeOutputAbstract implements BBCodeOutputInterface{
6565
*/
6666
protected $moduleInterfaces = [];
6767

68+
/**
69+
* @var string
70+
*/
71+
protected $eol = PHP_EOL;
72+
6873
/**
6974
* BBCodeOutputInterface constructor.
7075
*
@@ -73,6 +78,8 @@ abstract class BBCodeOutputAbstract implements BBCodeOutputInterface{
7378
* @param \Psr\Log\LoggerInterface $logger
7479
*/
7580
public function __construct(ContainerInterface $options, CacheInterface $cache, LoggerInterface $logger){
81+
$options->replacement_eol = $options->replacement_eol ?? $this->eol;
82+
7683
$this->options = $options;
7784
$this->cache = $cache;
7885
$this->logger = $logger;
@@ -113,6 +120,13 @@ public function getNoparse():array{
113120
return $this->noparse;
114121
}
115122

123+
/**
124+
* @return string
125+
*/
126+
public function getEOL():string{
127+
return $this->options->replacement_eol;
128+
}
129+
116130
/**
117131
* @inheritdoc
118132
*/

‎src/Output/BBCodeOutputInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public function getSingleTags():array;
4848
*/
4949
public function getNoparse():array;
5050

51+
/**
52+
* @return string
53+
*/
54+
public function getEOL():string;
55+
5156
/**
5257
* transforms the current bbcode
5358
*

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /