|
23 | 23 | from __future__ import annotations |
24 | 24 |
|
25 | 25 | import json |
26 | | -import re |
27 | 26 | from collections import defaultdict |
28 | 27 | from datetime import UTC, datetime |
29 | | -from html import escape as escape_html |
30 | 28 | from io import StringIO |
31 | 29 |
|
32 | 30 | from skillspector import __version__ as _skillspector_version |
33 | | -from skillspector.nodes.report import _clean_text |
| 31 | +from skillspector.nodes.report import _markdown_cell as _markdown_text |
| 32 | +from skillspector.nodes.report import _markdown_code |
| 33 | +from skillspector.nodes.report import _markdown_plain_text as _markdown_plain_text |
34 | 34 |
|
35 | 35 |
|
36 | 36 | def sorted_results(results: list[dict[str, object]]) -> list[dict[str, object]]: |
@@ -376,29 +376,6 @@ def _format_json(results: list[dict[str, object]]) -> str: |
376 | 376 | # ═══════════════════════════════════════════════════════════════════ |
377 | 377 |
|
378 | 378 |
|
379 | | -def _markdown_plain_text(value: object) -> str: |
380 | | - """Remove display controls and keep a Markdown field on one line.""" |
381 | | - text = _clean_text(str(value)) or "" |
382 | | - text = "".join(c for c in text if c.isprintable() or c.isspace()) |
383 | | - return " ".join(text.splitlines()) |
384 | | - |
385 | | - |
386 | | -def _markdown_text(value: object) -> str: |
387 | | - """Keep scan-derived prose within its own Markdown line.""" |
388 | | - text = escape_html(_markdown_plain_text(value), quote=False) |
389 | | - return re.sub(r"([\\`*_{}\[\]()#+.!|>~-])", r"\\\1", text) |
390 | | - |
391 | | - |
392 | | -def _markdown_code(value: object, *, table_cell: bool = False) -> str: |
393 | | - """Quote literal text without allowing code-span or table-cell breakouts.""" |
394 | | - text = _markdown_plain_text(value) |
395 | | - if table_cell: |
396 | | - text = text.replace("|", "\\|") |
397 | | - delimiter = "`" * (max((len(run) for run in re.findall(r"`+", text)), default=0) + 1) |
398 | | - padding = " " if text.startswith(("`", " ")) or text.endswith(("`", " ")) else "" |
399 | | - return f"{delimiter}{padding}{text}{padding}{delimiter}" |
400 | | - |
401 | | - |
402 | 379 | def _format_markdown(results: list[dict[str, object]]) -> str: |
403 | 380 | lines: list[str] = [] |
404 | 381 | total = len(results) |
|
0 commit comments