gitoria

tickets

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit6f6e57976f6e5797Tickets conductor: STATUS wordingmre6f6e5797/components/markdown.hl

6.3 KB

  1. // components/markdown.hl — A MARKDOWN TEXT, RENDERED (ticket #6): `Markdown { blocks = … }` with the
  2. // blocks of markdown.hl's markdownBlocks (the summary, a comment, a state note). The blocks are
  3. // plain data; every character of the source is a TEXT node here and a link's href was checked
  4. // by markdown.hl safeHref — no HTML string is ever built (no raw HTML, no scripts, no
  5. // `javascript:` links). Headings of the text become h3/h4/h5 (the page owns h1/h2). A table
  6. // (mission 013) is <markdown-table><table> with <th>/<td> carrying data-align (left/center/right/'').
  7. // The span markup is written out once per block kind: a View has no macros.
  8. blocks = []
  9. Style {
  10. markdownText {
  11. display = 'block'
  12. // Keep the combinator as a quoted nested key.
  13. '> :first-child' {
  14. marginTop = '0'
  15. }
  16. // Keep the combinator as a quoted nested key.
  17. '> :last-child' {
  18. marginBottom = '0'
  19. }
  20. p {
  21. whiteSpace = 'pre-wrap'
  22. margin = '.5rem 0'
  23. }
  24. h3 {
  25. margin = '.9rem 0 .4rem'
  26. lineHeight = '1.3'
  27. color = 'var(--color-text-strong)'
  28. fontSize = '1.15rem'
  29. }
  30. h4 {
  31. margin = '.9rem 0 .4rem'
  32. lineHeight = '1.3'
  33. color = 'var(--color-text-strong)'
  34. fontSize = '1.02rem'
  35. }
  36. h5 {
  37. margin = '.9rem 0 .4rem'
  38. lineHeight = '1.3'
  39. color = 'var(--color-text-strong)'
  40. fontSize = '.95rem'
  41. }
  42. ul {
  43. margin = '.5rem 0'
  44. paddingLeft = '1.4rem'
  45. listStyleType = 'disc'
  46. }
  47. ol {
  48. margin = '.5rem 0'
  49. paddingLeft = '1.4rem'
  50. listStyleType = 'decimal'
  51. }
  52. li {
  53. whiteSpace = 'pre-wrap'
  54. // Keep the combinator as a quoted nested key.
  55. '+ li' {
  56. marginTop = '.15rem'
  57. }
  58. }
  59. strong {
  60. color = 'var(--color-text-strong)'
  61. }
  62. a {
  63. textDecoration = 'underline'
  64. textUnderlineOffset = '.15em'
  65. overflowWrap = 'anywhere'
  66. }
  67. code {
  68. font = '.88em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'
  69. padding = '.05em .3em'
  70. color = 'var(--color-text-strong)'
  71. background = 'var(--color-background-sunken)'
  72. borderRadius = 'var(--radius-small)'
  73. }
  74. pre {
  75. margin = '.5rem 0'
  76. padding = '.6rem .7rem'
  77. overflowX = 'auto'
  78. background = 'var(--color-background-sunken)'
  79. borderRadius = 'var(--radius-small)'
  80. code {
  81. padding = '0'
  82. background = 'transparent'
  83. whiteSpace = 'pre'
  84. }
  85. }
  86. }
  87. markdownTable {
  88. display = 'block'
  89. maxWidth = '100%'
  90. overflowX = 'auto'
  91. margin = '.5rem 0'
  92. padding = '1px'
  93. contain = 'inline-size'
  94. table {
  95. borderCollapse = 'collapse'
  96. }
  97. th {
  98. padding = '.3rem .6rem'
  99. textAlign = 'start'
  100. verticalAlign = 'top'
  101. minWidth = '2.5rem'
  102. overflowWrap = 'normal'
  103. wordBreak = 'normal'
  104. fontWeight = '700'
  105. color = 'var(--color-text-strong)'
  106. }
  107. td {
  108. padding = '.3rem .6rem'
  109. textAlign = 'start'
  110. verticalAlign = 'top'
  111. minWidth = '2.5rem'
  112. overflowWrap = 'normal'
  113. wordBreak = 'normal'
  114. }
  115. // Keep the attribute selector; there is no bare form.
  116. '[data-align="left"]' {
  117. textAlign = 'left'
  118. }
  119. // Keep the attribute selector; there is no bare form.
  120. '[data-align="center"]' {
  121. textAlign = 'center'
  122. }
  123. // Keep the attribute selector; there is no bare form.
  124. '[data-align="right"]' {
  125. textAlign = 'right'
  126. }
  127. }
  128. }
  129. View {
  130. markdownText {
  131. for (b of blocks) {
  132. if (b.isP) { p {
  133. for (s of b.spans) {
  134. if (s.isText) { s.text }
  135. if (s.isStrong) { strong { s.text } }
  136. if (s.isEm) { em { s.text } }
  137. if (s.isStrongEm) { strong { em { s.text } } }
  138. if (s.isCode) { code { s.text } }
  139. if (s.isLink) { a { href = s.href rel = "nofollow noopener noreferrer" s.text } }
  140. }
  141. } }
  142. if (b.isH1) { h3 {
  143. for (s of b.spans) {
  144. if (s.isText) { s.text }
  145. if (s.isStrong) { strong { s.text } }
  146. if (s.isEm) { em { s.text } }
  147. if (s.isStrongEm) { strong { em { s.text } } }
  148. if (s.isCode) { code { s.text } }
  149. if (s.isLink) { a { href = s.href rel = "nofollow noopener noreferrer" s.text } }
  150. }
  151. } }
  152. if (b.isH2) { h4 {
  153. for (s of b.spans) {
  154. if (s.isText) { s.text }
  155. if (s.isStrong) { strong { s.text } }
  156. if (s.isEm) { em { s.text } }
  157. if (s.isStrongEm) { strong { em { s.text } } }
  158. if (s.isCode) { code { s.text } }
  159. if (s.isLink) { a { href = s.href rel = "nofollow noopener noreferrer" s.text } }
  160. }
  161. } }
  162. if (b.isH3) { h5 {
  163. for (s of b.spans) {
  164. if (s.isText) { s.text }
  165. if (s.isStrong) { strong { s.text } }
  166. if (s.isEm) { em { s.text } }
  167. if (s.isStrongEm) { strong { em { s.text } } }
  168. if (s.isCode) { code { s.text } }
  169. if (s.isLink) { a { href = s.href rel = "nofollow noopener noreferrer" s.text } }
  170. }
  171. } }
  172. if (b.isUl) { ul {
  173. for (it of b.items) { li {
  174. for (s of it.spans) {
  175. if (s.isText) { s.text }
  176. if (s.isStrong) { strong { s.text } }
  177. if (s.isEm) { em { s.text } }
  178. if (s.isStrongEm) { strong { em { s.text } } }
  179. if (s.isCode) { code { s.text } }
  180. if (s.isLink) { a { href = s.href rel = "nofollow noopener noreferrer" s.text } }
  181. }
  182. } }
  183. } }
  184. if (b.isOl) { ol { start = b.start
  185. for (it of b.items) { li {
  186. for (s of it.spans) {
  187. if (s.isText) { s.text }
  188. if (s.isStrong) { strong { s.text } }
  189. if (s.isEm) { em { s.text } }
  190. if (s.isStrongEm) { strong { em { s.text } } }
  191. if (s.isCode) { code { s.text } }
  192. if (s.isLink) { a { href = s.href rel = "nofollow noopener noreferrer" s.text } }
  193. }
  194. } }
  195. } }
  196. if (b.isCode) { pre { code { b.code } } }
  197. // mission 013: a pipe table, in a box that scrolls sideways when it is wider than the text
  198. if (b.isTable) { markdownTable { table {
  199. thead { tr {
  200. for (c of b.head) { th { "data-align" = c.align
  201. for (s of c.spans) {
  202. if (s.isText) { s.text }
  203. if (s.isStrong) { strong { s.text } }
  204. if (s.isEm) { em { s.text } }
  205. if (s.isStrongEm) { strong { em { s.text } } }
  206. if (s.isCode) { code { s.text } }
  207. if (s.isLink) { a { href = s.href rel = "nofollow noopener noreferrer" s.text } }
  208. }
  209. } }
  210. } }
  211. tbody {
  212. for (r of b.rows) { tr {
  213. for (c of r.cells) { td { "data-align" = c.align
  214. for (s of c.spans) {
  215. if (s.isText) { s.text }
  216. if (s.isStrong) { strong { s.text } }
  217. if (s.isEm) { em { s.text } }
  218. if (s.isStrongEm) { strong { em { s.text } } }
  219. if (s.isCode) { code { s.text } }
  220. if (s.isLink) { a { href = s.href rel = "nofollow noopener noreferrer" s.text } }
  221. }
  222. } }
  223. } }
  224. }
  225. } } }
  226. }
  227. }
  228. }

Branches

Latest commits

  • 6f6e5797Tickets conductor: STATUS wordingmre
  • 957de51fTickets conductor: T36 live, #36 review, #50 donemre
  • bc2fde32Merge branch 'main' into t36-stylemre
  • b7ca093atests: wait for the new row and normalize editor marker spacesmre
  • 41da3525Tickets conductor: flake cause, T36 deploy stepmre
  • 64c477e6Tickets conductor: deploy waits for Arachnemre
  • 467d7286Tickets conductor: T36 done, deploy questionmre
  • fed5ca81ticket_list: remove repeated selected-state coloursmre
  • 8542fc8aTickets conductor: T36 proof reviewedmre
  • 35980936inbox: preserve desktop columns after list styles were scopedmre
  • 2a5b8b91Tickets conductor: T36 cap stop, resumed for proofmre
  • c077a5cbstyles: format Style with nested language rulesmre
  • ccdde2beticket: format Style with nested language rulesmre
  • d083535bticket_list: nest Style rules and bare media queriesmre
  • c24608ebmarkdown: format Style with nested language rulesmre
  • de964b3bsettings: format Style with nested language rulesmre
  • 03c1de05new_project: format Style with nested language rulesmre
  • bd76cfa6connect: format Style with nested language rulesmre
  • 01fad593inbox: format Style with nested language rulesmre
  • 79dc9392you: format Style with nested language rulesmre