fix: render highlight language (#38793) (#38795)

backport #38793
This commit is contained in:
wxiaoguang
2026-08-06 18:34:28 +08:00
committed by GitHub
parent b71adfe1ad
commit 4e64b3a65d
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -215,7 +215,7 @@ func renderCellCode(output htmlutil.HTMLWriter, cell Cell, language string) erro
// Highlight code
lexer := highlight.DetectChromaLexerByFileName("", language)
output.WriteFormat(`<div class="cell-right cell-input"><pre><code class="chroma language-%s">`, strings.ToLower(language))
output.WriteFormat(`<div class="cell-right cell-input"><pre><code class="chroma language-%s">`, strings.ToLower(lexer.Config().Name))
output.WriteHTML(highlight.RenderCodeByLexer(lexer, source))
output.WriteHTML("</code></pre></div>")
}
+3 -3
View File
@@ -261,7 +261,7 @@ func TestIntegrationAndSanitization(t *testing.T) {
maliciousNotebook := `{
"nbformat": 4,
"nbformat_minor": 2,
"metadata": {},
"metadata": {"language_info":{"name":"any lang"}},
"cells": [
{
"cell_type": "code",
@@ -295,8 +295,8 @@ func TestIntegrationAndSanitization(t *testing.T) {
<div class="cell-line">
<div class="cell-left cell-prompt">In [1]:</div>
<div class="cell-right cell-input">
<pre><code class="chroma language-python">
<span class="n">a</span><span class="o">=</span><span class="mi">1</span>
<pre><code class="chroma language-fallback">
a=1
</code></pre>
</div>
</div>