Skip to content

Commit

Permalink
Fix for gutter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nimah79 committed Aug 28, 2024
1 parent 33e44c2 commit 97ec0d6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion tests/CommonMark/CodeBlockRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Foo {}
TXT;

$expected = <<<'TXT'
<pre data-lang="php" class="notranslate"><span class="hl-gutter">10</span> <span class="hl-keyword">class</span> <span class="hl-type">Foo</span> {}</pre>
<pre data-lang="php" class="notranslate"><span class="hl-gutter">10</span><span class="hl-keyword">class</span> <span class="hl-type">Foo</span> {}</pre>

TXT;

Expand Down
58 changes: 29 additions & 29 deletions tests/Languages/Base/Injections/GutterInjectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,22 @@ public function test_gutter_injection(): void
TXT;

$expected = <<<'TXT'
<span class="hl-gutter"> 10</span> <span class="hl-keyword">foreach</span> (<span class="hl-variable">$lines</span> <span class="hl-keyword">as</span> <span class="hl-variable">$i</span> =&gt; <span class="hl-variable">$line</span>) {
<span class="hl-gutter"> 11</span> <span class="hl-variable">$gutterNumber</span> = <span class="hl-variable">$gutterNumbers</span>[<span class="hl-variable">$i</span>];
<span class="hl-gutter"> 12</span>
<span class="hl-gutter"> 13</span> <span class="hl-variable">$gutterClass</span> = '<span class="hl-value">hl-gutter </span>' . (<span class="hl-variable">$this</span>-&gt;<span class="hl-property">classes</span>[<span class="hl-variable">$i</span> + 1] ?? '<span class="hl-value"></span>');
<span class="hl-gutter hl-gutter-addition">14 +</span> <span class="hl-addition"></span>
<span class="hl-gutter hl-gutter-addition">15 +</span> <span class="hl-addition"> <span class="hl-variable">$lines</span>[<span class="hl-variable">$i</span>] = <span class="hl-property">sprintf</span>(</span>
<span class="hl-gutter hl-gutter-addition">16 +</span> <span class="hl-addition"> <span class="hl-type">Escape</span>::<span class="hl-property">tokens</span>('<span class="hl-value">&lt;span class=&quot;%s&quot;&gt;%s&lt;/span&gt;%s</span>'),</span>
<span class="hl-gutter"> 17</span> <span class="hl-variable">$gutterClass</span>,
<span class="hl-gutter"> 18</span> <span class="hl-property">str_pad</span>(
<span class="hl-gutter hl-gutter-deletion">19 -</span> <span class="hl-property">string</span>: <span class="hl-deletion"><span class="hl-variable">$gutterNumber</span></span>,
<span class="hl-gutter"> 20</span> <span class="hl-property">length</span>: <span class="hl-variable">$gutterWidth</span>,
<span class="hl-gutter"> 21</span> <span class="hl-property">pad_type</span>: <span class="hl-property">STR_PAD_LEFT</span>,
<span class="hl-gutter"> 22</span> ),
<span class="hl-gutter"> 23</span> <span class="hl-variable">$line</span>,
<span class="hl-gutter"> 24</span> );
<span class="hl-gutter"> 25</span> }
<span class="hl-gutter"> 10</span><span class="hl-keyword">foreach</span> (<span class="hl-variable">$lines</span> <span class="hl-keyword">as</span> <span class="hl-variable">$i</span> =&gt; <span class="hl-variable">$line</span>) {
<span class="hl-gutter"> 11</span> <span class="hl-variable">$gutterNumber</span> = <span class="hl-variable">$gutterNumbers</span>[<span class="hl-variable">$i</span>];
<span class="hl-gutter"> 12</span>
<span class="hl-gutter"> 13</span> <span class="hl-variable">$gutterClass</span> = '<span class="hl-value">hl-gutter </span>' . (<span class="hl-variable">$this</span>-&gt;<span class="hl-property">classes</span>[<span class="hl-variable">$i</span> + 1] ?? '<span class="hl-value"></span>');
<span class="hl-gutter hl-gutter-addition">14 +</span><span class="hl-addition"></span>
<span class="hl-gutter hl-gutter-addition">15 +</span><span class="hl-addition"> <span class="hl-variable">$lines</span>[<span class="hl-variable">$i</span>] = <span class="hl-property">sprintf</span>(</span>
<span class="hl-gutter hl-gutter-addition">16 +</span><span class="hl-addition"> <span class="hl-type">Escape</span>::<span class="hl-property">tokens</span>('<span class="hl-value">&lt;span class=&quot;%s&quot;&gt;%s&lt;/span&gt;%s</span>'),</span>
<span class="hl-gutter"> 17</span> <span class="hl-variable">$gutterClass</span>,
<span class="hl-gutter"> 18</span> <span class="hl-property">str_pad</span>(
<span class="hl-gutter hl-gutter-deletion">19 -</span> <span class="hl-property">string</span>: <span class="hl-deletion"><span class="hl-variable">$gutterNumber</span></span>,
<span class="hl-gutter"> 20</span> <span class="hl-property">length</span>: <span class="hl-variable">$gutterWidth</span>,
<span class="hl-gutter"> 21</span> <span class="hl-property">pad_type</span>: <span class="hl-property">STR_PAD_LEFT</span>,
<span class="hl-gutter"> 22</span> ),
<span class="hl-gutter"> 23</span> <span class="hl-variable">$line</span>,
<span class="hl-gutter"> 24</span> );
<span class="hl-gutter"> 25</span>}
TXT;
$highlighter = (new Highlighter())->withGutter(10);

Expand All @@ -65,11 +65,11 @@ public function test_gutter_injection_one_single_line(): void
TXT;

$expected = <<<'TXT'
<span class="hl-gutter"> 10</span> <span class="hl-property">on</span>:
<span class="hl-gutter"> 11</span> <span class="hl-property">pull_request</span>:
<span class="hl-gutter"> 12</span> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review]
<span class="hl-gutter hl-gutter-addition">13 +</span> <span class="hl-addition"> <span class="hl-property">pull_request_target</span>: </span>
<span class="hl-gutter"> 14</span> <span class="hl-property">other</span>: foo
<span class="hl-gutter"> 10</span><span class="hl-property">on</span>:
<span class="hl-gutter"> 11</span> <span class="hl-property">pull_request</span>:
<span class="hl-gutter"> 12</span> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review]
<span class="hl-gutter hl-gutter-addition">13 +</span><span class="hl-addition"> <span class="hl-property">pull_request_target</span>: </span>
<span class="hl-gutter"> 14</span><span class="hl-property">other</span>: foo
TXT;

$highlighter = (new Highlighter())->withGutter(10);
Expand All @@ -91,14 +91,14 @@ public function test_gutter_injection_many_single_lines(): void
TXT;

$expected = <<<'TXT'
<span class="hl-gutter"> 10</span> <span class="hl-property">on</span>:
<span class="hl-gutter"> 11</span> <span class="hl-property">pull_request</span>:
<span class="hl-gutter"> 12</span> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review]
<span class="hl-gutter hl-gutter-addition">13 +</span> <span class="hl-addition"> <span class="hl-property">pull_request_target</span>: </span>
<span class="hl-gutter hl-gutter-addition">14 +</span> <span class="hl-addition"> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review] </span>
<span class="hl-gutter hl-gutter-addition">15 +</span> <span class="hl-addition"> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review] </span>
<span class="hl-gutter hl-gutter-addition">16 +</span> <span class="hl-addition"> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review] </span>
<span class="hl-gutter"> 17</span> <span class="hl-property">other</span>: foo
<span class="hl-gutter"> 10</span><span class="hl-property">on</span>:
<span class="hl-gutter"> 11</span> <span class="hl-property">pull_request</span>:
<span class="hl-gutter"> 12</span> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review]
<span class="hl-gutter hl-gutter-addition">13 +</span><span class="hl-addition"> <span class="hl-property">pull_request_target</span>: </span>
<span class="hl-gutter hl-gutter-addition">14 +</span><span class="hl-addition"> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review] </span>
<span class="hl-gutter hl-gutter-addition">15 +</span><span class="hl-addition"> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review] </span>
<span class="hl-gutter hl-gutter-addition">16 +</span><span class="hl-addition"> <span class="hl-property">types</span>: [opened, synchronize, reopened, ready_for_review] </span>
<span class="hl-gutter"> 17</span><span class="hl-property">other</span>: foo
TXT;

$highlighter = (new Highlighter())->withGutter(10);
Expand Down

0 comments on commit 97ec0d6

Please sign in to comment.