@@ -33,8 +33,7 @@ discard block |
||
| 33 | 33 | if (in_array($style, ["HTML", "MarkdownV2", "Markdown"])) |
| 34 | 34 | { |
| 35 | 35 | $this->style = $style; |
| 36 | - } |
|
| 37 | - else |
|
| 36 | + } else |
|
| 38 | 37 | { |
| 39 | 38 | throw new \InvalidArgumentException("Wrong style name"); |
| 40 | 39 | } |
@@ -156,24 +155,21 @@ discard block |
||
| 156 | 155 | { |
| 157 | 156 | //Manage the modifiers |
| 158 | 157 | $new_string_split[count($new_string_split) - 1] .= $str_split_unicode[$i]; //Apppend the modifier to the previous char |
| 159 | - } |
|
| 160 | - else |
|
| 158 | + } else |
|
| 161 | 159 | { |
| 162 | 160 | if ($codepoint == "200d") |
| 163 | 161 | { |
| 164 | 162 | //Manage the Zero Width Joiner |
| 165 | 163 | $new_string_split[count($new_string_split) - 1] .= $str_split_unicode[$i]; //Apppend the ZWJ to the previous char |
| 166 | 164 | $joiner = true; |
| 167 | - } |
|
| 168 | - else |
|
| 165 | + } else |
|
| 169 | 166 | { |
| 170 | 167 | if ($joiner) |
| 171 | 168 | { |
| 172 | 169 | //If previous one was a ZWJ |
| 173 | 170 | $new_string_split[count($new_string_split) - 1] .= $str_split_unicode[$i]; //Apppend to the previous char |
| 174 | 171 | $joiner = false; |
| 175 | - } |
|
| 176 | - else |
|
| 172 | + } else |
|
| 177 | 173 | { |
| 178 | 174 | $new_string_split[] = $str_split_unicode[$i]; //New char |
| 179 | 175 | } |
@@ -202,34 +198,28 @@ discard block |
||
| 202 | 198 | if ($char == $this->getEntityStartString($entity)) |
| 203 | 199 | { |
| 204 | 200 | return $char."\\".$char.$char; |
| 205 | - } |
|
| 206 | - else |
|
| 201 | + } else |
|
| 207 | 202 | { |
| 208 | 203 | return $char; |
| 209 | 204 | } |
| 210 | - } |
|
| 211 | - else |
|
| 205 | + } else |
|
| 212 | 206 | { |
| 213 | 207 | return $char; |
| 214 | 208 | } |
| 215 | - } |
|
| 216 | - else |
|
| 209 | + } else |
|
| 217 | 210 | { |
| 218 | 211 | if ($char == '*' || $char == '_' || $char == '[' || $char == '`') |
| 219 | 212 | { |
| 220 | 213 | return "\\".$char; |
| 221 | - } |
|
| 222 | - else |
|
| 214 | + } else |
|
| 223 | 215 | { |
| 224 | 216 | return $char; |
| 225 | 217 | } |
| 226 | 218 | } |
| 227 | - } |
|
| 228 | - else if ($this->style == 'HTML') |
|
| 219 | + } else if ($this->style == 'HTML') |
|
| 229 | 220 | { |
| 230 | 221 | return ($char == '<' ? '<' : ($char == '>' ? '>' : ($char == '&' ? '&' : $char))); |
| 231 | - } |
|
| 232 | - else if ($this->style == 'MarkdownV2') |
|
| 222 | + } else if ($this->style == 'MarkdownV2') |
|
| 233 | 223 | { |
| 234 | 224 | $isBlockquoteOpen = false; |
| 235 | 225 | foreach ($entities as $entity) { |
@@ -241,13 +231,11 @@ discard block |
||
| 241 | 231 | if($isBlockquoteOpen && $char == "\n") |
| 242 | 232 | { |
| 243 | 233 | return $char.'>'; |
| 244 | - } |
|
| 245 | - else |
|
| 234 | + } else |
|
| 246 | 235 | { |
| 247 | 236 | return (in_array($char, ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!', '\\']) ? '\\'.$char : $char); |
| 248 | 237 | } |
| 249 | - } |
|
| 250 | - else |
|
| 238 | + } else |
|
| 251 | 239 | { |
| 252 | 240 | return $char; |
| 253 | 241 | } |
@@ -294,8 +282,7 @@ discard block |
||
| 294 | 282 | break; |
| 295 | 283 | } |
| 296 | 284 | } |
| 297 | - } |
|
| 298 | - else if ($this->style == 'HTML') |
|
| 285 | + } else if ($this->style == 'HTML') |
|
| 299 | 286 | { |
| 300 | 287 | switch ($entity->type) |
| 301 | 288 | { |
@@ -354,8 +341,7 @@ discard block |
||
| 354 | 341 | break; |
| 355 | 342 | } |
| 356 | 343 | } |
| 357 | - } |
|
| 358 | - else if ($this->style == 'MarkdownV2') |
|
| 344 | + } else if ($this->style == 'MarkdownV2') |
|
| 359 | 345 | { |
| 360 | 346 | switch ($entity->type) |
| 361 | 347 | { |
@@ -478,8 +464,7 @@ discard block |
||
| 478 | 464 | break; |
| 479 | 465 | } |
| 480 | 466 | } |
| 481 | - } |
|
| 482 | - else if ($this->style == 'HTML') |
|
| 467 | + } else if ($this->style == 'HTML') |
|
| 483 | 468 | { |
| 484 | 469 | switch ($entity->type) |
| 485 | 470 | { |
@@ -534,8 +519,7 @@ discard block |
||
| 534 | 519 | break; |
| 535 | 520 | } |
| 536 | 521 | } |
| 537 | - } |
|
| 538 | - else if ($this->style == 'MarkdownV2') |
|
| 522 | + } else if ($this->style == 'MarkdownV2') |
|
| 539 | 523 | { |
| 540 | 524 | switch ($entity->type) |
| 541 | 525 | { |