Add test for syntax highlighting moonscript code block

This commit is contained in:
Catalin Constantin Mititiuc 2025-06-16 20:18:05 -07:00
parent 26f77eab9a
commit 3f39bfeae7

View File

@ -32,32 +32,40 @@ print("hello world")
assert.same [[<div class="highlight"><pre><span></span><code><span class="py-nb">print</span><span class="py-p">(</span><span class="py-s2">&quot;hello world&quot;</span><span class="py-p">)</span></code></pre></div>]], out assert.same [[<div class="highlight"><pre><span></span><code><span class="py-nb">print</span><span class="py-p">(</span><span class="py-s2">&quot;hello world&quot;</span><span class="py-p">)</span></code></pre></div>]], out
it "syntax highlights moonscript code", ->
out = flatten_html render [[
```moonscript
print "Hi, #{@name}!"
```]]
assert.same [[<div class="highlight"><pre><span></span><code><span class="py-nb">print</span><span class="py-s2">&quot;</span><span class="py-s">Hi, </span><span class="py-si">#{</span><span class="py-vc">@name</span><span class="py-si">}</span><span class="py-s">!</span><span class="py-s2">&quot;</span></code></pre></div>]], out
it "doesnt highlight code inside of a cosmo template", -> it "doesnt highlight code inside of a cosmo template", ->
site.user_vars.hello = (_, args) -> site.user_vars.hello = (_, args) ->
{ template } = args { template } = args
template template
out = flatten_html render [=[ out = flatten_html render [=[
```lua
print 5
```
$hello{[[
```lua ```lua
print 5 print thing
``` ```
$hello{[[ ]]}]=]
```lua
print thing
```
]]}]=]
assert.same [=[<div class="highlight"><pre><span></span><code><span class="py-nb">print</span><span class="py-mi">5</span></code></pre></div><p> assert.same [=[<div class="highlight"><pre><span></span><code><span class="py-nb">print</span><span class="py-mi">5</span></code></pre></div><p>
```lua ```lua
print thing print thing
``` ```
</p>]=], out </p>]=], out
it "doesn't highlight unrecognized code languages", -> it "doesn't highlight unrecognized code languages", ->
out = flatten_html render [[ out = flatten_html render [[
```snickerdoodle ```snickerdoodle
this code block has an unknown label this code block has an unknown label
```]] ```]]
assert.same [[<div class="sourceCode"><pre class="sourceCode"><code>this code block has an unknown label</code></pre></div>]], out assert.same [[<div class="sourceCode"><pre class="sourceCode"><code>this code block has an unknown label</code></pre></div>]], out