gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Brancho34-lists11dc8dea|||PR Document offline shell and keyed ordering framework gapsmreo34-lists/lib/import.hl

2.4 KB

  1. // lib/import.hl — the AntColony ticket file format (the import's parser), shared by tools/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. paras = []
  24. let cur = []
  25. for (raw of text.split(NL)) {
  26. 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. lines = text.split(NL)
  42. head = {}
  43. let i = 0
  44. while (i < lines.length && lines[i].trim() != '') {
  45. line = lines[i]
  46. 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. 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

  • 11dc8dea|||PR Document offline shell and keyed ordering framework gapsmre
  • ed091d44Merge branch 'records' into mainTickets
  • 180c0cdb|||PR records: ticket move live (M32), hybriel#439mre
  • 497cae7bMerge branch 'm32-move' into mainTickets
  • 772e0696|||PR Allow project admins to move tickets between their projectsmre
  • be92a560Merge branch 'records' into mainTickets
  • 0daf2ea8|||PR records: PR-only workflow, #50 donemre
  • 0185d0b6Log PR 1 deploymre
  • f5bf16e2Mission 031: deploy PR 1mre
  • c69cd5f3Merge branch 'pr-flow' into mainTickets
  • cc56798cLog gitoria PR-only requestmre
  • d876d0b2|||PR README: changes land as PRsmre
  • fd83ac1fconductor: caramboleyo is the user, not owner/creatorApollo
  • 3b858c91Log backup hard-link fixmre
  • 7f6b37a0deploy.sh backup: tar --hard-dereference (hard links broke mpackdb sidecars on restore)mre
  • e93711d9Log E30 livemre
  • 59c02e4dMerge e30: preserve edited state note labels in Markdownmre
  • 30970796Log E30 deploy GOmre
  • 7c8e6d83Limit edited state note fix to Markdown renderingmre
  • 910536d0Log E30 reviewmre