[debug/fix] ensure that not syntax highlighted code is a string

Otherwise it could be in another unrendered form that makes marko complains.

Closes #17256791

authorLaurent Peuch <cortex@worlddomination.be>
changeseta61e0fe17a69
branchdefault
phasepublic
hiddenno
parent revision#7d2c61d40fe9 [debug-toolbar] add registry decisions debug panel
child revision#be0864a2eec8 [mod] allow to pass generic additional arguments to pygments HtmlFormatter
files modified by this revision
cubicweb/misc/source_highlight.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1569558039 -7200
# Fri Sep 27 06:20:39 2019 +0200
# Node ID a61e0fe17a6952fcc1ef0f80729b01f8ab5aed36
# Parent 7d2c61d40fe9ab107fc10111c46b785e8304e17a
[debug/fix] ensure that not syntax highlighted code is a string

Otherwise it could be in another unrendered form that makes marko complains.

Closes #17256791

diff --git a/cubicweb/misc/source_highlight.py b/cubicweb/misc/source_highlight.py
@@ -22,11 +22,11 @@
1      return pygments_highlight(code, get_lexer_by_name(language), TerminalFormatter())
2 
3 
4  def highlight_html(code, language, linenos=False):
5      if not has_pygments:
6 -        return code
7 +        return str(code)
8 
9      return pygments_highlight(str(code), get_lexer_by_name(language), HtmlFormatter(wrapcode=True, linenos=linenos))
10 
11 
12  def generate_css():