tickets
All repositories: gitoria
2.4 KB
// ticketfile.hl — the AntColony ticket file format, shared by import.hl and the one-off// tools/fix-import-summaries.hl. Statics only (no top-level work: importing it runs nothing).//// A ticket file is `project:` and `subject:` header lines, a blank line, the summary.// The summary is HARD-WRAPPED text: lines are joined into paragraphs (one space between// them), a blank line starts a new paragraph, a list line starts a new line; paragraphs are separated by one empty line// ("\n\n") in the stored summary, which the ticket page renders with `white-space: pre-wrap`.// CRLF files work: every line is trim()med, which drops the carriage return. (Hybriel// strings have no escapes — "\r" would be two characters, so there is no CR constant.)static NL = ""// A MARKDOWN LIST LINE (`- `, `* `, `1. ` after trimming) stays its own line (ticket #15):// it starts a new line inside the paragraph ("\n"); a following ordinary line is still// joined onto it (a wrapped list item). Nested indentation is not kept.static isListLine = (line) => {if (line.startsWith('- ') || line.startsWith('* ')) { return true }let i = 0while (i < line.length && line.charCodeAt(i) >= 48 && line.charCodeAt(i) <= 57) { i = i + 1 }return i > 0 && line.slice(i, i + 2) == '. '}// hard-wrapped text → paragraphs joined by "\n\n" (list lines inside one by "\n")static paragraphsOf = (text) => {let paras = []let cur = []for (raw of text.split(NL)) {let line = raw.trim()if (line == '') {if (cur.length > 0) { paras.push(cur.join(NL)) }cur = []} else if (cur.length == 0 || isListLine(line)) {cur.push(line)} else {cur[cur.length - 1] = cur[cur.length - 1] + ' ' + line}}if (cur.length > 0) { paras.push(cur.join(NL)) }return paras.join(NL + NL)}// { project, subject, summary } or { error }static parse = (text) => {let lines = text.split(NL)let head = {}let i = 0while (i < lines.length && lines[i].trim() != '') {let line = lines[i]let c = line.indexOf(':')if (c > 0) { head[line.slice(0, c).trim().toLowerCase()] = line.slice(c + 1).trim() }i = i + 1}let body = []i = i + 1while (i < lines.length) {body.push(lines[i])i = i + 1}if (head.project == null || head.project == '') { return { error = 'no project: line' } }if (head.subject == null || head.subject == '') { return { error = 'no subject: line' } }return { project = head.project subject = head.subject summary = paragraphsOf(body.join(NL)) }}
Branches
- mainmain branch
Latest commits
- f12fa1bcState of 2026-09-27, before the move to gitoriamre