Skip to content

Commit

Permalink
Refactor to use the class directive
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Nov 17, 2024
1 parent 77af72a commit 3a92381
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<small class="relative {{ $torchlight ? '-top-1 right-3' : 'top-0 right-0' }} float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block"><span class="sr-only">Filepath: </span>{{ $path }}</small>
<small @class([
'relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block',
'-top-1 right-3' => $torchlight,
'top-0 right-0' => ! $torchlight,
])><span class="sr-only">Filepath: </span>{{ $path }}</small>
2 changes: 1 addition & 1 deletion packages/framework/tests/Feature/IncludesFacadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function testAdvancedMarkdownDocumentIsCompiledToHtml()
<h1>Heading</h1>
<p>This is a paragraph. It has some <strong>bold</strong> and <em>italic</em> text.</p>
<blockquote class="info"><p>Info Blockquote</p></blockquote>
<pre><code class="language-php"><small class="relative top-0 right-0 float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block"><span class="sr-only">Filepath: </span>hello.php</small>echo 'Hello, World!';
<pre><code class="language-php"><small class="relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block top-0 right-0"><span class="sr-only">Filepath: </span>hello.php</small>echo 'Hello, World!';
</code></pre>
<h2>Subheading</h2>
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function testProcessorExpandsFilepathDirectiveInStandardCodeblock()
HTML;

$expected = <<<'HTML'
<pre><code class="language-html"><small class="relative top-0 right-0 float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block"><span class="sr-only">Filepath: </span>foo.html</small></code></pre>
<pre><code class="language-html"><small class="relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block top-0 right-0"><span class="sr-only">Filepath: </span>foo.html</small></code></pre>
HTML;

$this->assertSame($expected, CodeblockFilepathProcessor::postprocess($html));
Expand All @@ -215,7 +215,7 @@ public function testProcessorExpandsFilepathDirectiveInTorchlightCodeblock()
HTML;

$expected = <<<'HTML'
<pre><code class="torchlight"><!-- Syntax highlighted by torchlight.dev --><small class="relative -top-1 right-3 float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block"><span class="sr-only">Filepath: </span>foo.html</small><div class="line"><span class="line-number">1</span>&nbsp;</div></code></pre>
<pre><code class="torchlight"><!-- Syntax highlighted by torchlight.dev --><small class="relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block -top-1 right-3"><span class="sr-only">Filepath: </span>foo.html</small><div class="line"><span class="line-number">1</span>&nbsp;</div></code></pre>
HTML;

$this->assertSame($expected, CodeblockFilepathProcessor::postprocess($html));
Expand All @@ -230,7 +230,7 @@ public function testProcessorEscapesHtmlByDefault()

$escaped = e('<a href="">Link</a>');
$expected = <<<HTML
<pre><code class="language-html"><small class="relative top-0 right-0 float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block"><span class="sr-only">Filepath: </span>$escaped</small></code></pre>
<pre><code class="language-html"><small class="relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block top-0 right-0"><span class="sr-only">Filepath: </span>$escaped</small></code></pre>
HTML;

$this->assertSame($expected, CodeblockFilepathProcessor::postprocess($html));
Expand All @@ -246,7 +246,7 @@ public function testProcessorDoesNotEscapeHtmlIfConfigured()
HTML;

$expected = <<<'HTML'
<pre><code class="language-html"><small class="relative top-0 right-0 float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block"><span class="sr-only">Filepath: </span><a href="">Link</a></small></code></pre>
<pre><code class="language-html"><small class="relative float-right opacity-50 hover:opacity-100 transition-opacity duration-250 not-prose hidden md:block top-0 right-0"><span class="sr-only">Filepath: </span><a href="">Link</a></small></code></pre>
HTML;

$this->assertSame($expected, CodeblockFilepathProcessor::postprocess($html));
Expand Down

0 comments on commit 3a92381

Please sign in to comment.