feat: VS Code-like syntax highlighting for code blocks
Code blocks in documents are now highlighted server-side with Pygments according to their language (Markdown fences and TinyMCE code samples), using VS Code "Dark+" colours in the viewer and a light variant in the print view. A language label is shown next to the copy button. Blocks marked as plain text/Cisco config stay unchanged; blocks without a language are only coloured when the language is detected confidently. Works offline, no CDN needed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
8458cbe8cf
commit
f7e1e21c24
6 files changed
+130
-1
No files matched your search
@@ -68,7 +68,10 @@ class Document(NetBoxModel):
|
||||
"padding-left", "padding-right", "padding-top", "text-align", "text-decoration",
|
||||
"text-indent", "vertical-align", "white-space", "width",
|
||||
})
|
||||
return bleach.clean(value, tags=tags, attributes=attributes, protocols=("http", "https", "mailto"), css_sanitizer=css)
|
||||
from .highlighting import highlight_code_blocks
|
||||
|
||||
cleaned = bleach.clean(value, tags=tags, attributes=attributes, protocols=("http", "https", "mailto"), css_sanitizer=css)
|
||||
return highlight_code_blocks(cleaned)
|
||||
|
||||
|
||||
class DocumentCategory(NetBoxModel):
|
||||
|
||||
Reference in new issue
Block a user