gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit78073baa78073baamain: format Style with nested language rulesmre78073baa/lib/markdown.hl

19.9 KB

  1. // markdown.hl — MARKDOWN IN TEXT FIELDS (ticket tickets.worldapi.org#6, mission 014; CONCEPT.md
  2. // "Data formats": Markdown inside text fields). The summary, comment texts and state notes are
  3. // Markdown; the ticket page renders them. Statics only, server realm.
  4. //
  5. // SAFE BY CONSTRUCTION: the text is parsed HERE into plain data — blocks of spans — and the
  6. // View (components/markdown.hl) builds elements from it. Every character of the source ends
  7. // up in a TEXT node (hl:web escapes it); there is no HTML string anywhere, so raw HTML in the
  8. // source (`<script>`, `<img onerror>`) is shown as the text it is. A link's href is taken only
  9. // if `safeHref` accepts it: http(s):, mailto:, a same-site path (`/…`, not `//…`) or `#…`;
  10. // anything else (`javascript:`, `data:`, `vbscript:`, relative `foo`, quotes, spaces, control
  11. // characters) stays plain text.
  12. //
  13. // WHAT IS UNDERSTOOD (the subset ticket #6 names — headings, lists, code, links, emphasis):
  14. // blocks: `#`…`######` headings, `-`/`*`/`+` and `1.`/`1)` list items (one level; deeper
  15. // indentation is flattened; a list may interrupt a paragraph — the import writes
  16. // them that way), ``` / ~~~ fenced code, paragraphs (blank-line separated; their
  17. // single line breaks are KEPT — the page showed them before, `white-space: pre-wrap`)
  18. // inline: `code` (any backtick run), [text](url), <https://…>, bare http(s):// URLs,
  19. // *em* _em_ **strong** __strong__ ***both***, backslash escapes of punctuation
  20. // tables: GitHub pipe tables (mission 013, the rules of notes#5 — see "tables" below)
  21. // Not understood (shown as typed): block quotes, images, nested lists, HTML.
  22. //
  23. // A block: { isP | isH1 | isH2 | isH3 | isUl | isOl | isCode, spans, items: [{ spans }],
  24. // start (ol), code (text of a code block) }; a table block also has isTable = true,
  25. // head: [{ spans, align }] and rows: [{ cells: [{ spans, align }] }] (align '' | left |
  26. // center | right). The other blocks carry no isTable (their page data stays as it was).
  27. // A span: { text, isText | isStrong | isEm | isStrongEm | isCode | isLink, href }
  28. static NL = "
  29. "
  30. static isSpaceC = (c) => { return c == 32 || c == 9 || c == 10 || c == 13 }
  31. static isAlnumC = (c) => { return (c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c > 127 }
  32. static isPunctC = (c) => { return (c >= 33 && c <= 47) || (c >= 58 && c <= 64) || (c >= 91 && c <= 96) || (c >= 123 && c <= 126) }
  33. // ---- links ------------------------------------------------------------------------------
  34. // the href of a link, or null when it is not one we let through
  35. static safeHref = (u) => {
  36. if (u == null) { return null }
  37. t = ('' + u).trim()
  38. if (t == '' || t.length > 2000) { return null }
  39. let i = 0
  40. while (i < t.length) {
  41. c = t.charCodeAt(i)
  42. // no spaces / control characters, no quotes, no < > ` and no backslash
  43. if (c <= 32 || c == 127 || c == 34 || c == 39 || c == 60 || c == 62 || c == 96 || c == 92) { return null }
  44. i = i + 1
  45. }
  46. low = t.toLowerCase()
  47. if (low.startsWith('https://') && t.length > 8) { return t }
  48. if (low.startsWith('http://') && t.length > 7) { return t }
  49. if (low.startsWith('mailto:') && t.length > 7) { return t }
  50. if (t.startsWith('/') && !t.startsWith('//')) { return t }
  51. if (t.startsWith('#')) { return t }
  52. return null
  53. }
  54. static isUrlStart = (s, i) => {
  55. low = s.slice(i, i + 8).toLowerCase()
  56. return low.startsWith('https://') || low.startsWith('http://')
  57. }
  58. // where a bare URL starting at i ends: up to whitespace or < > " `, minus trailing punctuation
  59. // (and a closing parenthesis that has no opening one inside the URL)
  60. static isUrlStop = (c) => { return isSpaceC(c) || c == 60 || c == 62 || c == 34 || c == 96 }
  61. static urlEnd = (s, i) => {
  62. let end = i
  63. while (end < s.length && !isUrlStop(s.charCodeAt(end))) { end = end + 1 }
  64. let trimming = true
  65. while (trimming && end > i) {
  66. c = s.charCodeAt(end - 1)
  67. if (c == 46 || c == 44 || c == 59 || c == 58 || c == 33 || c == 63 || c == 39 || c == 42 || c == 95) {
  68. end = end - 1
  69. } else if (c == 41) {
  70. let opens = 0
  71. let closes = 0
  72. let k = i
  73. while (k < end) {
  74. if (s.charCodeAt(k) == 40) { opens = opens + 1 }
  75. if (s.charCodeAt(k) == 41) { closes = closes + 1 }
  76. k = k + 1
  77. }
  78. if (closes > opens) { end = end - 1 } else { trimming = false }
  79. } else {
  80. trimming = false
  81. }
  82. }
  83. return end
  84. }
  85. // `[label](url)` at i → { label, href (null = not allowed), end } or null (not a link)
  86. static linkAt = (s, i) => {
  87. let j = i + 1
  88. let found = -1
  89. while (j < s.length && found < 0) {
  90. c = s.charCodeAt(j)
  91. if (c == 91) { return null }
  92. if (c == 93) { found = j }
  93. j = j + 1
  94. }
  95. if (found < 0 || found == i + 1) { return null }
  96. if (found + 1 >= s.length || s.charCodeAt(found + 1) != 40) { return null }
  97. k = s.indexOf(')', found + 2)
  98. if (k < 0) { return null }
  99. let target = s.slice(found + 2, k).trim()
  100. // an optional title after a space is dropped: [x](url "title")
  101. sp = target.indexOf(' ')
  102. if (sp > 0) { target = target.slice(0, sp) }
  103. return { label = s.slice(i + 1, found) href = safeHref(target) end = k + 1 }
  104. }
  105. // ---- spans --------------------------------------------------------------------------------
  106. static textSpan = (t, strong, em) => {
  107. return { text = t isText = !strong && !em isStrong = strong && !em isEm = em && !strong isStrongEm = strong && em isCode = false isLink = false href = '' }
  108. }
  109. static codeSpan = (t) => {
  110. return { text = t isText = false isStrong = false isEm = false isStrongEm = false isCode = true isLink = false href = '' }
  111. }
  112. static linkSpan = (t, h) => {
  113. return { text = t isText = false isStrong = false isEm = false isStrongEm = false isCode = false isLink = true href = h }
  114. }
  115. // the index of a run of EXACTLY n characters c at or after `at`, or -1. `esc`: a character
  116. // after a backslash does not count (emphasis; inside `code` a backslash is just a backslash)
  117. static runAt = (s, at, c, n, esc) => {
  118. let i = at
  119. while (i < s.length) {
  120. if (esc && s.charCodeAt(i) == 92) {
  121. i = i + 2
  122. } else if (s.charCodeAt(i) == c) {
  123. let k = i
  124. while (k < s.length && s.charCodeAt(k) == c) { k = k + 1 }
  125. if (k - i == n) { return i }
  126. i = k
  127. } else {
  128. i = i + 1
  129. }
  130. }
  131. return -1
  132. }
  133. // is there a CLOSING delimiter run (exactly n of c, not after a space; `_` not before a
  134. // letter/digit) after `at`?
  135. static hasCloser = (s, at, c, n) => {
  136. let i = at
  137. while (i < s.length) {
  138. r = runAt(s, i, c, n, true)
  139. if (r < 0) { return false }
  140. prev = r > 0 ? s.charCodeAt(r - 1) : 32
  141. next = r + n < s.length ? s.charCodeAt(r + n) : 32
  142. if (r > at && !isSpaceC(prev) && (c != 95 || !isAlnumC(next))) { return true }
  143. i = r + n
  144. }
  145. return false
  146. }
  147. static inlineSpans = (src) => {
  148. out = []
  149. if (src == null || src == '') { return out }
  150. s = '' + src
  151. n = s.length
  152. let buf = ''
  153. let strong = false
  154. let em = false
  155. let strongC = 0
  156. let emC = 0
  157. let i = 0
  158. while (i < n) {
  159. c = s.charCodeAt(i)
  160. if (c == 92 && i + 1 < n && isPunctC(s.charCodeAt(i + 1))) {
  161. // a backslash escape: the next punctuation character as itself
  162. buf = buf + s[i + 1]
  163. i = i + 2
  164. } else if (c == 96) {
  165. // `code`: a run of backticks up to the same run
  166. let k = i
  167. while (k < n && s.charCodeAt(k) == 96) { k = k + 1 }
  168. close = runAt(s, k, 96, k - i, false)
  169. if (close < 0) {
  170. buf = buf + s.slice(i, k)
  171. i = k
  172. } else {
  173. if (buf != '') { out.push(textSpan(buf, strong, em)) }
  174. buf = ''
  175. let code = s.slice(k, close).replaceAll(NL, ' ')
  176. if (code.length > 2 && code.startsWith(' ') && code.endsWith(' ') && code.trim() != '') { code = code.slice(1, code.length - 1) }
  177. out.push(codeSpan(code))
  178. i = close + (k - i)
  179. }
  180. } else if (c == 91) {
  181. // [label](url)
  182. l = linkAt(s, i)
  183. if (l == null) {
  184. buf = buf + '['
  185. i = i + 1
  186. } else if (l.href == null) {
  187. buf = buf + s.slice(i, l.end)
  188. i = l.end
  189. } else {
  190. if (buf != '') { out.push(textSpan(buf, strong, em)) }
  191. buf = ''
  192. out.push(linkSpan(l.label, l.href))
  193. i = l.end
  194. }
  195. } else if (c == 60 && i + 1 < n && isUrlStart(s, i + 1)) {
  196. // <https://…>
  197. e = s.indexOf('>', i + 1)
  198. url = e > 0 ? s.slice(i + 1, e) : ''
  199. h = safeHref(url)
  200. if (e < 0 || h == null) {
  201. buf = buf + '<'
  202. i = i + 1
  203. } else {
  204. if (buf != '') { out.push(textSpan(buf, strong, em)) }
  205. buf = ''
  206. out.push(linkSpan(url, h))
  207. i = e + 1
  208. }
  209. } else if ((c == 104 || c == 72) && (i == 0 || !isAlnumC(s.charCodeAt(i - 1))) && isUrlStart(s, i)) {
  210. // a bare http(s):// URL
  211. e = urlEnd(s, i)
  212. url = s.slice(i, e)
  213. h = safeHref(url)
  214. if (h == null) {
  215. buf = buf + s[i]
  216. i = i + 1
  217. } else {
  218. if (buf != '') { out.push(textSpan(buf, strong, em)) }
  219. buf = ''
  220. out.push(linkSpan(url, h))
  221. i = e
  222. }
  223. } else if (c == 42 || c == 95) {
  224. // * and _: emphasis (1), strong (2), both (3)
  225. let k = i
  226. while (k < n && s.charCodeAt(k) == c) { k = k + 1 }
  227. run = k - i
  228. prev = i > 0 ? s.charCodeAt(i - 1) : 32
  229. next = k < n ? s.charCodeAt(k) : 32
  230. wantStrong = run == 2 || run == 3
  231. wantEm = run == 1 || run == 3
  232. canOpen = !isSpaceC(next) && (c == 42 || !isAlnumC(prev))
  233. canClose = !isSpaceC(prev) && (c == 42 || !isAlnumC(next))
  234. closes = canClose && run <= 3 && (!wantStrong || (strong && strongC == c)) && (!wantEm || (em && emC == c))
  235. opens = !closes && canOpen && run <= 3 && (!wantStrong || !strong) && (!wantEm || !em) && hasCloser(s, k, c, run)
  236. if (closes || opens) {
  237. if (buf != '') { out.push(textSpan(buf, strong, em)) }
  238. buf = ''
  239. if (wantStrong) {
  240. strong = opens
  241. strongC = c
  242. }
  243. if (wantEm) {
  244. em = opens
  245. emC = c
  246. }
  247. } else {
  248. buf = buf + s.slice(i, k)
  249. }
  250. i = k
  251. } else {
  252. buf = buf + s[i]
  253. i = i + 1
  254. }
  255. }
  256. if (buf != '') { out.push(textSpan(buf, strong, em)) }
  257. return out
  258. }
  259. // ---- blocks -------------------------------------------------------------------------------
  260. static noCr = (line) => { return line.length > 0 && line.charCodeAt(line.length - 1) == 13 ? line.slice(0, line.length - 1) : line }
  261. static indentOf = (line) => {
  262. let i = 0
  263. while (i < line.length && (line.charCodeAt(i) == 32 || line.charCodeAt(i) == 9)) { i = i + 1 }
  264. return i
  265. }
  266. // a heading line (≤ 3 spaces in, 1–6 '#', a space or the end) → { level, text } or null
  267. static headingOf = (line) => {
  268. if (indentOf(line) > 3) { return null }
  269. t = line.trim()
  270. let k = 0
  271. while (k < t.length && t.charCodeAt(k) == 35) { k = k + 1 }
  272. if (k == 0 || k > 6) { return null }
  273. if (k < t.length && t.charCodeAt(k) != 32 && t.charCodeAt(k) != 9) { return null }
  274. let body = t.slice(k).trim()
  275. // a closing run of '#' after a space goes
  276. let e = body.length
  277. while (e > 0 && body.charCodeAt(e - 1) == 35) { e = e - 1 }
  278. if (e == 0) { body = '' } else if (e < body.length && (body.charCodeAt(e - 1) == 32 || body.charCodeAt(e - 1) == 9)) { body = body.slice(0, e).trim() }
  279. return { level = k text = body }
  280. }
  281. // a list item line → { ordered, start, text } or null
  282. static itemOf = (line) => {
  283. t = line.trim()
  284. if (t.length >= 2 && (t.charCodeAt(0) == 45 || t.charCodeAt(0) == 42 || t.charCodeAt(0) == 43) && (t.charCodeAt(1) == 32 || t.charCodeAt(1) == 9)) {
  285. return { ordered = false start = 1 text = t.slice(2).trim() }
  286. }
  287. if (t.length == 1 && (t == '-' || t == '*' || t == '+')) { return { ordered = false start = 1 text = '' } }
  288. let k = 0
  289. while (k < t.length && k < 9 && t.charCodeAt(k) >= 48 && t.charCodeAt(k) <= 57) { k = k + 1 }
  290. if (k == 0 || k >= t.length) { return null }
  291. d = t.charCodeAt(k)
  292. if (d != 46 && d != 41) { return null }
  293. if (k + 1 < t.length && t.charCodeAt(k + 1) != 32 && t.charCodeAt(k + 1) != 9) { return null }
  294. return { ordered = true start = toNumber(t.slice(0, k)) text = t.slice(k + 1).trim() }
  295. }
  296. // a code fence line (``` or ~~~, ≥ 3) → its run (e.g. '````') or null
  297. static fenceOf = (line) => {
  298. if (indentOf(line) > 3) { return null }
  299. t = line.trim()
  300. if (t.length < 3) { return null }
  301. c = t.charCodeAt(0)
  302. if (c != 96 && c != 126) { return null }
  303. let k = 0
  304. while (k < t.length && t.charCodeAt(k) == c) { k = k + 1 }
  305. if (k < 3) { return null }
  306. // an info string after ``` must not contain a backtick
  307. if (c == 96 && t.slice(k).includes('`')) { return null }
  308. return t.slice(0, k)
  309. }
  310. // ---- tables (GitHub pipe tables, mission 013 = notes#5's rules, notes reports/003-md-tables.md) ----
  311. // A table is a HEADER row with a DELIMITER row right under it that has the same number of cells
  312. // (`|---|:--:|--:|`: each cell `:?-+:?`, the colons set left / center / right; it must hold a `|`).
  313. // BODY rows follow up to a blank line, a heading, a fence or a list item; a short row is padded
  314. // with empty cells, a long one cut. Cells are split at every `|` that is not escaped (`\|` is a
  315. // pipe in the cell, also inside `code`); the outer pipes are optional; a cell is inline Markdown.
  316. // A table may interrupt a paragraph. A line with pipes but no delimiter row under it stays text.
  317. // is the character at k escaped: an odd run of backslashes right before it (not before `start`)?
  318. static escapedAt = (s, k, start) => {
  319. let n = 0
  320. while (k - 1 - n >= start && s.charCodeAt(k - 1 - n) == 92) { n = n + 1 }
  321. return n % 2 == 1
  322. }
  323. // a row's cells (trimmed source texts), split at every unescaped `|`; outer pipes are optional
  324. static rowCells = (s) => {
  325. let a = 0
  326. let b = s.length
  327. while (a < b && isSpaceC(s.charCodeAt(a))) { a = a + 1 }
  328. while (b > a && isSpaceC(s.charCodeAt(b - 1))) { b = b - 1 }
  329. if (a < b && s.charCodeAt(a) == 124) { a = a + 1 }
  330. if (b > a && s.charCodeAt(b - 1) == 124 && !escapedAt(s, b - 1, a)) { b = b - 1 }
  331. cells = []
  332. let start = a
  333. let k = a
  334. while (k < b) {
  335. if (s.charCodeAt(k) == 92 && k + 1 < b) {
  336. k = k + 2
  337. } else {
  338. if (s.charCodeAt(k) == 124) {
  339. cells.push(s.slice(start, k).trim())
  340. start = k + 1
  341. }
  342. k = k + 1
  343. }
  344. }
  345. cells.push(s.slice(start, b).trim())
  346. return cells
  347. }
  348. // a cell's Markdown: `\|` becomes `|`, every other escape stays for inlineSpans
  349. static unpipe = (t) => {
  350. let out = ''
  351. let k = 0
  352. while (k < t.length) {
  353. if (t.charCodeAt(k) == 92 && k + 1 < t.length) {
  354. out = out + (t.charCodeAt(k + 1) == 124 ? '|' : t.slice(k, k + 2))
  355. k = k + 2
  356. } else {
  357. out = out + t[k]
  358. k = k + 1
  359. }
  360. }
  361. return out
  362. }
  363. // one delimiter cell (`:?-+:?`) → '' | 'left' | 'center' | 'right', or null when it is not one
  364. static alignOfCell = (c) => {
  365. n = c.length
  366. l = n > 0 && c.charCodeAt(0) == 58
  367. a = l ? 1 : 0
  368. r = n > a && c.charCodeAt(n - 1) == 58
  369. b = r ? n - 1 : n
  370. if (b <= a) { return null }
  371. let k = a
  372. while (k < b) {
  373. if (c.charCodeAt(k) != 45) { return null }
  374. k = k + 1
  375. }
  376. if (l && r) { return 'center' }
  377. if (r) { return 'right' }
  378. if (l) { return 'left' }
  379. return ''
  380. }
  381. // the delimiter row → its alignments, or null
  382. static alignsOf = (line) => {
  383. if (indentOf(line) > 3 || !line.includes('|')) { return null }
  384. out = []
  385. for (c of rowCells(line)) {
  386. al = alignOfCell(c)
  387. if (al == null) { return null }
  388. out.push(al)
  389. }
  390. return out
  391. }
  392. // a table starting at line i (a header row + a delimiter row with as many cells) → { aligns, head } or null
  393. static tableAt = (lines, i) => {
  394. if (i + 1 >= lines.length) { return null }
  395. head = noCr(lines[i])
  396. if (indentOf(head) > 3 || head.trim() == '') { return null }
  397. aligns = alignsOf(noCr(lines[i + 1]))
  398. if (aligns == null) { return null }
  399. cells = rowCells(head)
  400. if (cells.length != aligns.length) { return null }
  401. return { aligns = aligns head = cells }
  402. }
  403. // a row's cells → [{ spans, align }], exactly as many as the table has columns
  404. static tableRow = (cells, aligns) => {
  405. out = []
  406. let k = 0
  407. while (k < aligns.length) {
  408. src = k < cells.length ? unpipe(cells[k]) : ''
  409. let spans = inlineSpans(src)
  410. out.push({ spans = spans align = aligns[k] })
  411. k = k + 1
  412. }
  413. return out
  414. }
  415. static tableBlock = (head, rows) => {
  416. return { isP = false isH1 = false isH2 = false isH3 = false isUl = false isOl = false isCode = false isTable = true spans = [] items = [] start = 1 code = '' head = head rows = rows }
  417. }
  418. static paraBlock = (lines) => {
  419. let spans = inlineSpans(lines.join(NL))
  420. return { isP = true isH1 = false isH2 = false isH3 = false isUl = false isOl = false isCode = false spans = spans items = [] start = 1 code = '' }
  421. }
  422. static headingBlock = (level, text) => {
  423. let spans = inlineSpans(text)
  424. return { isP = false isH1 = level == 1 isH2 = level == 2 isH3 = level >= 3 isUl = false isOl = false isCode = false spans = spans items = [] start = 1 code = '' }
  425. }
  426. static codeBlock = (lines) => {
  427. text = lines.join(NL)
  428. return { isP = false isH1 = false isH2 = false isH3 = false isUl = false isOl = false isCode = true spans = [] items = [] start = 1 code = text }
  429. }
  430. static listBlock = (ordered, first, itemLines) => {
  431. let items = []
  432. for (lines of itemLines) {
  433. let spans = inlineSpans(lines.join(NL))
  434. items.push({ spans = spans })
  435. }
  436. return { isP = false isH1 = false isH2 = false isH3 = false isUl = !ordered isOl = ordered isCode = false spans = [] items = items start = first code = '' }
  437. }
  438. // the Markdown text → blocks (see the header)
  439. static markdownBlocks = (text) => {
  440. out = []
  441. if (text == null || text == '') { return out }
  442. lines = ('' + text).split(NL)
  443. let para = []
  444. let inList = false
  445. let listOrdered = false
  446. let listStart = 1
  447. let items = []
  448. let blankBefore = false
  449. let i = 0
  450. while (i < lines.length) {
  451. line = noCr(lines[i])
  452. fence = fenceOf(line)
  453. h = fence == null ? headingOf(line) : null
  454. it = fence == null && h == null ? itemOf(line) : null
  455. tb = fence == null && h == null && it == null ? tableAt(lines, i) : null
  456. if (fence != null) {
  457. if (para.length > 0) { out.push(paraBlock(para)) }
  458. para = []
  459. if (inList) { out.push(listBlock(listOrdered, listStart, items)) }
  460. inList = false
  461. items = []
  462. code = []
  463. let j = i + 1
  464. let closed = false
  465. fc = fence.charCodeAt(0)
  466. while (j < lines.length && !closed) {
  467. l = noCr(lines[j])
  468. f = fenceOf(l)
  469. if (f != null && f.charCodeAt(0) == fc && f.length >= fence.length && l.trim() == f) {
  470. closed = true
  471. } else {
  472. code.push(l)
  473. }
  474. j = j + 1
  475. }
  476. out.push(codeBlock(code))
  477. i = j
  478. blankBefore = false
  479. } else if (line.trim() == '') {
  480. if (para.length > 0) { out.push(paraBlock(para)) }
  481. para = []
  482. blankBefore = true
  483. i = i + 1
  484. } else if (h != null) {
  485. if (para.length > 0) { out.push(paraBlock(para)) }
  486. para = []
  487. if (inList) { out.push(listBlock(listOrdered, listStart, items)) }
  488. inList = false
  489. items = []
  490. out.push(headingBlock(h.level, h.text))
  491. blankBefore = false
  492. i = i + 1
  493. } else if (tb != null) {
  494. // a table: the header, the delimiter row, then every line up to a blank line or another block
  495. if (para.length > 0) { out.push(paraBlock(para)) }
  496. para = []
  497. if (inList) { out.push(listBlock(listOrdered, listStart, items)) }
  498. inList = false
  499. items = []
  500. head = tableRow(tb.head, tb.aligns)
  501. rows = []
  502. let j = i + 2
  503. let more = true
  504. while (more && j < lines.length) {
  505. l = noCr(lines[j])
  506. if (l.trim() == '' || fenceOf(l) != null || headingOf(l) != null || itemOf(l) != null) {
  507. more = false
  508. } else {
  509. rows.push({ cells = tableRow(rowCells(l), tb.aligns) })
  510. j = j + 1
  511. }
  512. }
  513. out.push(tableBlock(head, rows))
  514. i = j
  515. blankBefore = false
  516. } else if (it != null) {
  517. if (para.length > 0) { out.push(paraBlock(para)) }
  518. para = []
  519. if (inList && listOrdered != it.ordered) {
  520. out.push(listBlock(listOrdered, listStart, items))
  521. inList = false
  522. items = []
  523. }
  524. if (!inList) {
  525. inList = true
  526. listOrdered = it.ordered
  527. listStart = it.start
  528. items = []
  529. }
  530. items.push([it.text])
  531. blankBefore = false
  532. i = i + 1
  533. } else if (inList && (!blankBefore || indentOf(line) >= 2)) {
  534. // a wrapped item line (or an indented paragraph of the item): onto the last item
  535. last = items[items.length - 1]
  536. last.push(line.trim())
  537. items[items.length - 1] = last
  538. blankBefore = false
  539. i = i + 1
  540. } else {
  541. if (inList) { out.push(listBlock(listOrdered, listStart, items)) }
  542. inList = false
  543. items = []
  544. para.push(line.trim())
  545. blankBefore = false
  546. i = i + 1
  547. }
  548. }
  549. if (para.length > 0) { out.push(paraBlock(para)) }
  550. if (inList) { out.push(listBlock(listOrdered, listStart, items)) }
  551. return out
  552. }

Branches

Latest commits

  • 78073baamain: format Style with nested language rulesmre
  • 5499c290Sync theme unchanged from layouts 17e0f03mre
  • fd33ee21Sync reviewed components from 8176eb1mre
  • 93348453Re-vendor tickets to Hybriel set day35mre
  • a4123831tickets#42: the /connect and /login/callback error pages are app pages: the function routes redirect to /connect/failed/<code> and /login/failed/<code> (components/problem.hl, sentences in lib/problems.hl), htmlPage and its hand-written stylesheet are gone; gate tests/error-pages.mjsmre
  • cefc7b4atickets: a startup error prints its message before exit 1 (hybriel#247)mre
  • 99bd6570tickets: lib/migrate.hl writes no table of another topic any more: projects.hl rewriteSlug / addProjectNamed / hasMembers, tickets.hl moveToProject / ticketRecords / ticketRecordsOf, events.hl renameStates / eventRecords / eventRecordsOf; the migration calls them (tickets#47)mre
  • b57161e3tickets: the markup names its own rules (Style.pMessage, Style.olTickets, ...) instead of hand-written class strings that copy a stylesheet rule; the shared bodies sit in lib/looks.hl (tickets#38)mre
  • f767b24dtickets: 111 needless let became plain declarations (3 in ticket.hl, ticket_list.hl, comments.hl and 108 never-reassigned, not captured loop-body ones); the 212 really reassigned lets stay (tickets#44)mre
  • 16c0d3b5tickets: the modal window is phone first: the full-screen sheet is the base rule, the centred window sits in the min-width 60rem block (tickets#39)mre
  • 090ee809tickets: every component's styles in its own nested Style {} block; styles.hl keeps only the theme inherit, the accent and the site-wide rules (tickets#36)mre
  • d395763ftickets: ident-access gate ports 8769/8768 (8797 is taken on loreana)mre
  • afb9a403tickets: an ident access key (Authorization: Bearer idt_…) works in the API (ident#27 app side): lib/ident-access.hl copied from components, read keys GET only, ident down 503; gate tests/ident-access-tickets.mjsmre
  • 48c1ba79tickets: md-paste-files gate with the file manager casesmre
  • f04afc43tickets: MdEditor from components 59704ce (a file manager copy still attaches, pipe rows, tickets#49)mre
  • 06599fa0tickets: MdEditor from components b0f1ec2 (a clipboard with text always pastes the text, tickets#49); real Ctrl+V gatemre
  • 2e1b116ftickets: re-vendor Hybriel master acaceaf3 (framework ec8d6c1d): plugins/web patch queue while a page is built, anonymous session cookies refresh; gate waits for the comment editors to draw (W174) and clicks the form editor when it stands still; security gate: main's code runs on its own binary, lazy-session cookie checksmre
  • 361bc0fetickets: re-vendor Hybriel 7a684920 (WIP, not deployed); on Error exits 1 at startup; migrate passes its log by reference; gate checks follow lazy sessions and the 413 refusalmre
  • 8a69999cident#28: /login/callback never signs out the session it finds; a valid code puts the user on the same sessionmre
  • 337e9b21tickets#37: a comment's files are open to everyone who can read the commentmre