[mod] allow to pass generic additional arguments to pygments HtmlFormatter
authorLaurent Peuch <cortex@worlddomination.be>
Wed, 25 Sep 2019 05:42:47 +0200
changeset 12770 be0864a2eec8
parent 12769 a61e0fe17a69
child 12771 70597b447fb7
[mod] allow to pass generic additional arguments to pygments HtmlFormatter
cubicweb/misc/source_highlight.py
--- a/cubicweb/misc/source_highlight.py	Fri Sep 27 06:20:39 2019 +0200
+++ b/cubicweb/misc/source_highlight.py	Wed Sep 25 05:42:47 2019 +0200
@@ -22,11 +22,13 @@
     return pygments_highlight(code, get_lexer_by_name(language), TerminalFormatter())
 
 
-def highlight_html(code, language, linenos=False):
+def highlight_html(code, language, linenos=False, linenostart=1, **kwargs):
     if not has_pygments:
         return str(code)
 
-    return pygments_highlight(str(code), get_lexer_by_name(language), HtmlFormatter(wrapcode=True, linenos=linenos))
+    return pygments_highlight(str(code),
+                              get_lexer_by_name(language),
+                              HtmlFormatter(wrapcode=True, linenos=linenos, linenostart=linenostart, **kwargs))
 
 
 def generate_css():