diff --git a/src/Languages/Base/Injections/AdditionInjection.php b/src/Languages/Base/Injections/AdditionInjection.php
index 8ef5ba0..4c5405a 100644
--- a/src/Languages/Base/Injections/AdditionInjection.php
+++ b/src/Languages/Base/Injections/AdditionInjection.php
@@ -15,6 +15,9 @@
{
public function parse(string $content, Highlighter $highlighter): ParsedInjection
{
+ // Standardize line endings
+ $content = preg_replace('/\R/', PHP_EOL, $content);
+
$content = str_replace('❷span class=❹ignore❹❸{+❷/span❸', '{+', $content);
$content = str_replace('❷span class=❹ignore❹❸+}❷/span❸', '+}', $content);
diff --git a/src/Languages/Base/Injections/DeletionInjection.php b/src/Languages/Base/Injections/DeletionInjection.php
index 8fef3b2..b4b6680 100644
--- a/src/Languages/Base/Injections/DeletionInjection.php
+++ b/src/Languages/Base/Injections/DeletionInjection.php
@@ -15,6 +15,9 @@
{
public function parse(string $content, Highlighter $highlighter): ParsedInjection
{
+ // Standardize line endings
+ $content = preg_replace('/\R/', PHP_EOL, $content);
+
$content = str_replace('❷span class=❹ignore❹❸{-❷/span❸', '{-', $content);
$content = str_replace('❷span class=❹ignore❹❸-}❷/span❸', '-}', $content);
diff --git a/src/Languages/Base/Injections/GutterInjection.php b/src/Languages/Base/Injections/GutterInjection.php
index e1f6ec9..669b2af 100644
--- a/src/Languages/Base/Injections/GutterInjection.php
+++ b/src/Languages/Base/Injections/GutterInjection.php
@@ -58,7 +58,8 @@ public function parse(string $content, Highlighter $highlighter): ParsedInjectio
foreach ($lines as $i => $line) {
$gutterNumber = $gutterNumbers[$i];
- $gutterClass = 'hl-gutter ' . ($this->classes[$i + $this->startAt] ?? '');
+ $hasClasses = $this->classes[$i + $this->startAt] ?? '';
+ $gutterClass = 'hl-gutter' . ($hasClasses ? ' ' . $hasClasses : '');
$lines[$i] = sprintf(
Escape::tokens('%s %s'),
diff --git a/src/Themes/InlineTheme.php b/src/Themes/InlineTheme.php
index 09906d0..8a3bba6 100644
--- a/src/Themes/InlineTheme.php
+++ b/src/Themes/InlineTheme.php
@@ -58,7 +58,7 @@ public function before(TokenType $tokenType): string
$style = $this->map[".{$class}"] ?? null;
if (! $style) {
- return '';
+ return "";
}
return "";
diff --git a/tests/CommonMark/CodeBlockRendererTest.php b/tests/CommonMark/CodeBlockRendererTest.php
index 2a3f953..3febb79 100644
--- a/tests/CommonMark/CodeBlockRendererTest.php
+++ b/tests/CommonMark/CodeBlockRendererTest.php
@@ -53,7 +53,7 @@ class Foo {}
TXT;
$expected = <<<'TXT'
-10 class Foo {}
+10 class Foo {}
TXT;
diff --git a/tests/Languages/Base/Injections/GutterInjectionTest.php b/tests/Languages/Base/Injections/GutterInjectionTest.php
index 2724790..92d0457 100644
--- a/tests/Languages/Base/Injections/GutterInjectionTest.php
+++ b/tests/Languages/Base/Injections/GutterInjectionTest.php
@@ -32,22 +32,22 @@ public function test_gutter_injection(): void
TXT;
$expected = <<<'TXT'
- 10 foreach ($lines as $i => $line) {
- 11 $gutterNumber = $gutterNumbers[$i];
- 12
- 13 $gutterClass = 'hl-gutter ' . ($this->classes[$i + 1] ?? '');
+ 10 foreach ($lines as $i => $line) {
+ 11 $gutterNumber = $gutterNumbers[$i];
+ 12
+ 13 $gutterClass = 'hl-gutter ' . ($this->classes[$i + 1] ?? '');
14 +
15 + $lines[$i] = sprintf(
16 + Escape::tokens('<span class="%s">%s</span>%s'),
- 17 $gutterClass,
- 18 str_pad(
+ 17 $gutterClass,
+ 18 str_pad(
19 - string: $gutterNumber,
- 20 length: $gutterWidth,
- 21 pad_type: STR_PAD_LEFT,
- 22 ),
- 23 $line,
- 24 );
- 25 }
+ 20 length: $gutterWidth,
+ 21 pad_type: STR_PAD_LEFT,
+ 22 ),
+ 23 $line,
+ 24 );
+ 25 }
TXT;
$highlighter = (new Highlighter())->withGutter(10);
@@ -65,11 +65,11 @@ public function test_gutter_injection_one_single_line(): void
TXT;
$expected = <<<'TXT'
- 10 on:
- 11 pull_request:
- 12 types: [opened, synchronize, reopened, ready_for_review]
+ 10 on:
+ 11 pull_request:
+ 12 types: [opened, synchronize, reopened, ready_for_review]
13 + pull_request_target:
- 14 other: foo
+ 14 other: foo
TXT;
$highlighter = (new Highlighter())->withGutter(10);
@@ -91,14 +91,14 @@ public function test_gutter_injection_many_single_lines(): void
TXT;
$expected = <<<'TXT'
- 10 on:
- 11 pull_request:
- 12 types: [opened, synchronize, reopened, ready_for_review]
+ 10 on:
+ 11 pull_request:
+ 12 types: [opened, synchronize, reopened, ready_for_review]
13 + pull_request_target:
14 + types: [opened, synchronize, reopened, ready_for_review]
15 + types: [opened, synchronize, reopened, ready_for_review]
16 + types: [opened, synchronize, reopened, ready_for_review]
- 17 other: foo
+ 17 other: foo
TXT;
$highlighter = (new Highlighter())->withGutter(10);