Skip to content

Commit

Permalink
Fix ListItem and Hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
DvogelHallowelt committed Nov 25, 2024
1 parent 0fb4018 commit dfb1566
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Converter/PostProcessors/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public function process( string $text ): string {
// remove leading / which is placed by pandoc between File: and the file title
$regEx = '#<color(.*?)>(.*?)</color>#';
$text = preg_replace_callback( $regEx, static function ( $matches ) {
$color = $matches[1];
$text = $matches[2];
$color = $matches[1];
$text = $matches[2];
$replacement = '<span style="color: ' . trim( $color ) . '">' . $text . '</span>';
return $replacement;
}, $text );
Expand Down
7 changes: 4 additions & 3 deletions src/Converter/PostProcessors/Hidden.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ public function process( string $text ): string {
$hide = $matches[2];
$flags = $matches[3];
$text = $matches[4];


$replacement = '<div class="mw-collapsible" data-expandtext="' . $show . '" data-collapsetext="' . $hide . '">';

$replacement = '<div class="mw-collapsible" data-expandtext="';
$replacement .= $show;
$replacement .= '" data-collapsetext="' . $hide . '">';
$replacement .= $text;
$replacement .= '</div>';

Expand Down
5 changes: 3 additions & 2 deletions src/Converter/PostProcessors/ListItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function process( string $text ): string {

if ( $posStar !== false && $posStar === 0 ) {
$this->splitList( '*', $line, $output );
} else if ( $posHash !== false && $posHash === 0 ) {
} elseif ( $posHash !== false && $posHash === 0 ) {
$this->splitList( '#', $line, $output );
} else {
$output[] = $line;
Expand All @@ -32,7 +32,8 @@ public function process( string $text ): string {

private function splitList( string $separator, string $line, array &$output ): void {
$listLines = explode( $separator, $line );
array_shift( $listLines ); // get rid of first empty element
// get rid of first empty element
array_shift( $listLines );

$newLine = '';
foreach ( $listLines as $listLine ) {
Expand Down

0 comments on commit dfb1566

Please sign in to comment.