diff --git a/strictdoc/export/html/generators/source_file_view_generator.py b/strictdoc/export/html/generators/source_file_view_generator.py
index de36ccde1..1745c44dc 100644
--- a/strictdoc/export/html/generators/source_file_view_generator.py
+++ b/strictdoc/export/html/generators/source_file_view_generator.py
@@ -1,5 +1,5 @@
# mypy: disable-error-code="no-untyped-call,no-untyped-def,operator"
-from typing import List, Tuple
+from typing import List, Tuple, Union
from markupsafe import Markup, escape
from pygments import highlight
@@ -89,7 +89,19 @@ def get_pygmented_source_lines(
source_file: SourceFile,
source_file_lines: List[str],
coverage_info: SourceFileTraceabilityInfo,
- ) -> Tuple[List[Markup], Markup]:
+ ) -> Tuple[
+ List[
+ Union[
+ Markup,
+ Tuple[
+ Markup,
+ Markup,
+ Union[ForwardRangeMarker, LineMarker, RangeMarker],
+ ],
+ ]
+ ],
+ Markup,
+ ]:
assert isinstance(source_file, SourceFile)
assert isinstance(source_file_lines, list)
assert isinstance(coverage_info, SourceFileTraceabilityInfo)
@@ -178,15 +190,18 @@ def get_pygmented_source_lines(
for pragma in coverage_info.pragmas:
pragma_line = pragma.ng_source_line_begin
if isinstance(pragma, ForwardRangeMarker):
- pygmented_source_file_lines[pragma_line - 1] = (
+ before_line = (
pygmented_source_file_lines[pragma_line - 1].rstrip("\n")
- + " ",
- "\n",
+ + " "
+ )
+ pygmented_source_file_lines[pragma_line - 1] = (
+ Markup(before_line),
+ Markup("\n"),
pragma,
)
continue
- source_line = source_file_lines[pragma_line - 1]
+ source_line = escape(source_file_lines[pragma_line - 1])
assert len(pragma.reqs_objs) > 0
before_line = source_line[
@@ -203,8 +218,8 @@ def get_pygmented_source_lines(
after_line = source_line[closing_bracket_index:].rstrip()
pygmented_source_file_lines[pragma_line - 1] = (
- escape(before_line),
- escape(after_line),
+ before_line,
+ after_line,
pragma,
)
pygments_styles = (
@@ -212,6 +227,8 @@ def get_pygmented_source_lines(
+ html_formatter.get_style_defs(".highlight")
)
- return list(map(Markup, pygmented_source_file_lines)), Markup(
- pygments_styles
+ as_markup = map(
+ lambda l: l if isinstance(l, tuple) else Markup(l),
+ pygmented_source_file_lines,
)
+ return list(as_markup), Markup(pygments_styles)