Render ticket descriptions as markdown (#114)
Lint / JS (eslint) (push) Successful in 17s
Lint / PHP requirements (version + extensions) (push) Successful in 39s
Lint / JS (eslint) (pull_request) Successful in 33s
Lint / PHP (phpcs PSR-12) (pull_request) Successful in 1m3s
Lint / PHP requirements (version + extensions) (pull_request) Successful in 58s
Lint / Deploy (pull_request) Skipped
Lint / Notify on failure (pull_request) Skipped
Security / PHP Security (semgrep) (push) Successful in 2m52s
Security / PHP Security (semgrep) (pull_request) Successful in 3m2s
Lint / PHP (phpcs PSR-12) (push) Successful in 48s
Lint / Deploy (push) Skipped
Lint / Notify on failure (push) Skipped

The ticket page escaped descriptions to plain text, so headings, lists,
tables, bold and code from Gandalf, MCP and manual tickets showed raw.
renderDescriptionView() now uses parseMarkdown(), the same sanitising
parser as comments, and the view drops pre-wrap for normal white space
like markdown comments do. The edit view still shows the raw source.

The parser also no longer treats underscores inside words as emphasis,
so identifiers like node_network_up stay literal (in comments too).

hwmonDaemon's fixed-width box layout loses its alignment as markdown;
LotusGuild/hwmonDaemon#38 switches it to markdown and converts its past
tickets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 01:02:02 -05:00
1 parent aad3e8eb44
commit fb2df0ee49
4 files changed
+11 -8

No files matched your search

+1
View File
@@ -226,6 +226,7 @@ Content-Type: application/json
- **Deduplication**: Generates a SHA-256 hash from the issue category, hostname, and device (no time window). A repeat alert matching an existing **open** ticket updates its title/description and escalates the priority if the condition worsened; if the matching ticket was already **closed**, it is reopened instead of creating a new one
- Cluster-wide issues (Ceph health, etc.) deduplicate across all nodes (hostname excluded from hash)
- Automated network tickets are keyed per problem, not just per host: on the optional `check_code` payload field when sent (it must name the instance, e.g. `iface_down:enp3s0`), otherwise on the title text outside the `[tags]`. After deploying this change (#116), run `php scripts/rehash_network_tickets.php --dry-run`, then without `--dry-run`, so open network tickets keep matching their alerts. The hash logic lives in `helpers/TicketHash.php`
- `description` is rendered as markdown on the ticket page, the same as markdown comments (#114). Reporters should send markdown: `##` sections, tables for key/value data and fenced code blocks for raw command output. Fixed-width box layouts lose their alignment.
- Matrix notification sent automatically on ticket creation, priority escalation, and reopen
- API key must be generated at `/admin/api-keys`; the key goes in hwmonDaemon's `/etc/hwmonDaemon/.env` as `TICKET_API_KEY`
+3 -3
View File
@@ -360,9 +360,9 @@ kbd {
padding: 0.5rem 0.25rem;
line-height: 1.75;
color: var(--text-primary);
/* pre-wrap preserves newlines and multiple spaces so ASCII art aligns correctly.
font-mono is inherited from body, so box-drawing characters line up. */
white-space: pre-wrap;
/* Rendered markdown (#114): the parser's <p>/<br> control line breaks,
as for markdown comments (.comment-text[data-markdown]). */
white-space: normal;
word-break: break-word;
}
.ticket-description-view p {
+4 -2
View File
@@ -80,11 +80,13 @@ function parseMarkdown(markdown) {
// Bold (**text** or __text__)
html = html.replace(/\*\*(.+?)\*\*/g, '<strong>$1</strong>');
html = html.replace(/__(.+?)__/g, '<strong>$1</strong>');
// Underscores only count when not inside a word (as in CommonMark), so
// identifiers like node_network_up or __init__.py stay literal.
html = html.replace(/(?<![A-Za-z0-9_])__(?!\s)(.+?)(?<!\s)__(?![A-Za-z0-9_])/g, '<strong>$1</strong>');
// Italic (*text* or _text_)
html = html.replace(/\*(.+?)\*/g, '<em>$1</em>');
html = html.replace(/_(.+?)_/g, '<em>$1</em>');
html = html.replace(/(?<![A-Za-z0-9_])_(?!\s)(.+?)(?<!\s)_(?![A-Za-z0-9_])/g, '<em>$1</em>');
// Strikethrough (~~text~~) — must run before subscript (~)
html = html.replace(/~~(.+?)~~/g, '<del>$1</del>');
+3 -3
View File
@@ -89,9 +89,9 @@ function renderDescriptionView() {
if (!raw.trim()) {
viewDiv.innerHTML = '<p class="lt-text-muted lt-text-sm"><em>No description provided.</em></p>';
} else {
// Ticket descriptions are plain text. CSS white-space:pre-wrap handles
// line breaks and multiple spaces (ASCII art) — no <br> replacement needed.
viewDiv.innerHTML = lt.escHtml(raw);
// Descriptions are markdown, rendered like comments (#114).
// parseMarkdown() escapes HTML first and allowlists link protocols.
viewDiv.innerHTML = parseMarkdown(raw);
}
}