gitoriaLog in with ident

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commite01c2b1de01c2b1dtickets#24: installable app (manifest, service worker, offline list), own icon; gate waits for the hello's pongmree01c2b1d/ticketfile.hl

2.4 KB

  1. // ticketfile.hl — the AntColony ticket file format, shared by import.hl and the one-off
  2. // tools/fix-import-summaries.hl. Statics only (no top-level work: importing it runs nothing).
  3. //
  4. // A ticket file is `project:` and `subject:` header lines, a blank line, the summary.
  5. // The summary is HARD-WRAPPED text: lines are joined into paragraphs (one space between
  6. // them), a blank line starts a new paragraph, a list line starts a new line; paragraphs are separated by one empty line
  7. // ("\n\n") in the stored summary, which the ticket page renders with `white-space: pre-wrap`.
  8. // CRLF files work: every line is trim()med, which drops the carriage return. (Hybriel
  9. // strings have no escapes — "\r" would be two characters, so there is no CR constant.)
  10. static NL = "
  11. "
  12. // A MARKDOWN LIST LINE (`- `, `* `, `1. ` after trimming) stays its own line (ticket #15):
  13. // it starts a new line inside the paragraph ("\n"); a following ordinary line is still
  14. // joined onto it (a wrapped list item). Nested indentation is not kept.
  15. static isListLine = (line) => {
  16. if (line.startsWith('- ') || line.startsWith('* ')) { return true }
  17. let i = 0
  18. while (i < line.length && line.charCodeAt(i) >= 48 && line.charCodeAt(i) <= 57) { i = i + 1 }
  19. return i > 0 && line.slice(i, i + 2) == '. '
  20. }
  21. // hard-wrapped text → paragraphs joined by "\n\n" (list lines inside one by "\n")
  22. static paragraphsOf = (text) => {
  23. let paras = []
  24. let cur = []
  25. for (raw of text.split(NL)) {
  26. let line = raw.trim()
  27. if (line == '') {
  28. if (cur.length > 0) { paras.push(cur.join(NL)) }
  29. cur = []
  30. } else if (cur.length == 0 || isListLine(line)) {
  31. cur.push(line)
  32. } else {
  33. cur[cur.length - 1] = cur[cur.length - 1] + ' ' + line
  34. }
  35. }
  36. if (cur.length > 0) { paras.push(cur.join(NL)) }
  37. return paras.join(NL + NL)
  38. }
  39. // { project, subject, summary } or { error }
  40. static parse = (text) => {
  41. let lines = text.split(NL)
  42. let head = {}
  43. let i = 0
  44. while (i < lines.length && lines[i].trim() != '') {
  45. let line = lines[i]
  46. let c = line.indexOf(':')
  47. if (c > 0) { head[line.slice(0, c).trim().toLowerCase()] = line.slice(c + 1).trim() }
  48. i = i + 1
  49. }
  50. let body = []
  51. i = i + 1
  52. while (i < lines.length) {
  53. body.push(lines[i])
  54. i = i + 1
  55. }
  56. if (head.project == null || head.project == '') { return { error = 'no project: line' } }
  57. if (head.subject == null || head.subject == '') { return { error = 'no subject: line' } }
  58. return { project = head.project subject = head.subject summary = paragraphsOf(body.join(NL)) }
  59. }

Branches

Latest commits

  • e01c2b1dtickets#24: installable app (manifest, service worker, offline list), own icon; gate waits for the hello's pongmre
  • 752fbb7fdeploy.sh: back up live storage/.sessions/.env before every deploy (newest 5 kept)mre
  • 38bdd5e4deploy.sh: never send .git or .gitignore to Byrodinmre
  • f12fa1bcState of 2026-09-27, before the move to gitoriamre