tables.unit 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. >>> basic table
  2. head | cells
  3. -----|------
  4. body | cells
  5. <<<
  6. <table>
  7. <thead>
  8. <tr>
  9. <th>head</th>
  10. <th>cells</th>
  11. </tr>
  12. </thead>
  13. <tbody>
  14. <tr>
  15. <td>body</td>
  16. <td>cells</td>
  17. </tr>
  18. </tbody>
  19. </table>
  20. >>> multiple rows
  21. head | cells
  22. -----|------
  23. body | cells
  24. more | cells
  25. <<<
  26. <table>
  27. <thead>
  28. <tr>
  29. <th>head</th>
  30. <th>cells</th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. <tr>
  35. <td>body</td>
  36. <td>cells</td>
  37. </tr>
  38. <tr>
  39. <td>more</td>
  40. <td>cells</td>
  41. </tr>
  42. </tbody>
  43. </table>
  44. >>> rows wrapped in pipes
  45. | head | cells |
  46. |------|-------|
  47. | body | cells |
  48. <<<
  49. <table>
  50. <thead>
  51. <tr>
  52. <th>head</th>
  53. <th>cells</th>
  54. </tr>
  55. </thead>
  56. <tbody>
  57. <tr>
  58. <td>body</td>
  59. <td>cells</td>
  60. </tr>
  61. </tbody>
  62. </table>
  63. >>> rows wrapped in pipes, whitespace alignment row
  64. | head | cells |
  65. | -- | --- |
  66. | body | cells |
  67. <<<
  68. <table>
  69. <thead>
  70. <tr>
  71. <th>head</th>
  72. <th>cells</th>
  73. </tr>
  74. </thead>
  75. <tbody>
  76. <tr>
  77. <td>body</td>
  78. <td>cells</td>
  79. </tr>
  80. </tbody>
  81. </table>
  82. >>> rows wrapped in pipes, tabs in whitespace
  83. | head | cells |
  84. | -- | --- |
  85. | body | cells |
  86. <<<
  87. <table>
  88. <thead>
  89. <tr>
  90. <th>head</th>
  91. <th>cells</th>
  92. </tr>
  93. </thead>
  94. <tbody>
  95. <tr>
  96. <td>body</td>
  97. <td>cells</td>
  98. </tr>
  99. </tbody>
  100. </table>
  101. >>> cells with inline syntax
  102. head `code` | _cells_
  103. ------------|--------
  104. *text* | <span>text</span>
  105. <<<
  106. <table>
  107. <thead>
  108. <tr>
  109. <th>head <code>code</code></th>
  110. <th><em>cells</em></th>
  111. </tr>
  112. </thead>
  113. <tbody>
  114. <tr>
  115. <td><em>text</em></td>
  116. <td><span>text</span></td>
  117. </tr>
  118. </tbody>
  119. </table>
  120. >>> cells are parsed before inline syntax
  121. header | _foo | bar_
  122. -------|------------|---
  123. text | text
  124. <<<
  125. <table>
  126. <thead>
  127. <tr>
  128. <th>header</th>
  129. <th>_foo</th>
  130. <th>bar_</th>
  131. </tr>
  132. </thead>
  133. <tbody>
  134. <tr>
  135. <td>text</td>
  136. <td>text</td>
  137. <td></td>
  138. </tr>
  139. </tbody>
  140. </table>
  141. >>> cells contain reference links
  142. header | header
  143. -------|--------
  144. text | [link][here]
  145. [here]: http://url
  146. <<<
  147. <table>
  148. <thead>
  149. <tr>
  150. <th>header</th>
  151. <th>header</th>
  152. </tr>
  153. </thead>
  154. <tbody>
  155. <tr>
  156. <td>text</td>
  157. <td><a href="http://url">link</a></td>
  158. </tr>
  159. </tbody>
  160. </table>
  161. >>> one column tables
  162. head
  163. -----|
  164. body
  165. <<<
  166. <table>
  167. <thead>
  168. <tr>
  169. <th>head</th>
  170. </tr>
  171. </thead>
  172. <tbody>
  173. <tr>
  174. <td>body</td>
  175. </tr>
  176. </tbody>
  177. </table>
  178. >>> varying cells per row
  179. head | foo | bar
  180. -----|-----|-----
  181. body
  182. row with | two cells
  183. <<<
  184. <table>
  185. <thead>
  186. <tr>
  187. <th>head</th>
  188. <th>foo</th>
  189. <th>bar</th>
  190. </tr>
  191. </thead>
  192. <tbody>
  193. <tr>
  194. <td>body</td>
  195. <td></td>
  196. <td></td>
  197. </tr>
  198. <tr>
  199. <td>row with</td>
  200. <td>two cells</td>
  201. <td></td>
  202. </tr>
  203. </tbody>
  204. </table>
  205. >>> left, center, and right alignment
  206. head | cells | here
  207. :----|:-----:|----:
  208. body | cells | here
  209. too | many | cells | here
  210. <<<
  211. <table>
  212. <thead>
  213. <tr>
  214. <th align="left">head</th>
  215. <th align="center">cells</th>
  216. <th align="right">here</th>
  217. </tr>
  218. </thead>
  219. <tbody>
  220. <tr>
  221. <td align="left">body</td>
  222. <td align="center">cells</td>
  223. <td align="right">here</td>
  224. </tr>
  225. <tr>
  226. <td align="left">too</td>
  227. <td align="center">many</td>
  228. <td align="right">cells</td>
  229. </tr>
  230. </tbody>
  231. </table>
  232. >>> left, center, and right alignment, with whitespace
  233. head | cells | here
  234. :-- | :---: | ---:
  235. body | cells | here
  236. too | many | cells | here
  237. <<<
  238. <table>
  239. <thead>
  240. <tr>
  241. <th align="left">head</th>
  242. <th align="center">cells</th>
  243. <th align="right">here</th>
  244. </tr>
  245. </thead>
  246. <tbody>
  247. <tr>
  248. <td align="left">body</td>
  249. <td align="center">cells</td>
  250. <td align="right">here</td>
  251. </tr>
  252. <tr>
  253. <td align="left">too</td>
  254. <td align="center">many</td>
  255. <td align="right">cells</td>
  256. </tr>
  257. </tbody>
  258. </table>
  259. >>> escape pipe
  260. | Name | Character |
  261. | --- | --- |
  262. | Backtick | ` |
  263. | Pipe | \| |
  264. <<<
  265. <table>
  266. <thead>
  267. <tr>
  268. <th>Name</th>
  269. <th>Character</th>
  270. </tr>
  271. </thead>
  272. <tbody>
  273. <tr>
  274. <td>Backtick</td>
  275. <td>`</td>
  276. </tr>
  277. <tr>
  278. <td>Pipe</td>
  279. <td>|</td>
  280. </tr>
  281. </tbody>
  282. </table>
  283. >>> escape pipe, preserve trailing whitespace
  284. | Name | Character |
  285. | --- | --- |
  286. | Pipe | \| abcdef |
  287. <<<
  288. <table>
  289. <thead>
  290. <tr>
  291. <th>Name</th>
  292. <th>Character</th>
  293. </tr>
  294. </thead>
  295. <tbody>
  296. <tr>
  297. <td>Pipe</td>
  298. <td>| abcdef</td>
  299. </tr>
  300. </tbody>
  301. </table>
  302. >>> trailing whitespace after final pipe
  303. | Name | Character |
  304. | --- | --- |
  305. | Pipe | abcdef |
  306. <<<
  307. <table>
  308. <thead>
  309. <tr>
  310. <th>Name</th>
  311. <th>Character</th>
  312. </tr>
  313. </thead>
  314. <tbody>
  315. <tr>
  316. <td>Pipe</td>
  317. <td>abcdef</td>
  318. </tr>
  319. </tbody>
  320. </table>
  321. >>> issue #531
  322. | A | [B](url) | C |
  323. |---|---|
  324. | a | b | c |
  325. <<<
  326. <p>| A | <a href="url">B</a> | C |
  327. |---|---|
  328. | a | b | c |</p>
  329. >>> trailing whitespace after delimiter row
  330. | Name | Value |
  331. | --- | --- |
  332. | Foo | bar |
  333. <<<
  334. <table>
  335. <thead>
  336. <tr>
  337. <th>Name</th>
  338. <th>Value</th>
  339. </tr>
  340. </thead>
  341. <tbody>
  342. <tr>
  343. <td>Foo</td>
  344. <td>bar</td>
  345. </tr>
  346. </tbody>
  347. </table>
  348. >>> can interrupt a paragraph
  349. paragraph
  350. foo | bar
  351. --- | ---
  352. baz | bim
  353. <<<
  354. <p>paragraph</p>
  355. <table>
  356. <thead>
  357. <tr>
  358. <th>foo</th>
  359. <th>bar</th>
  360. </tr>
  361. </thead>
  362. <tbody>
  363. <tr>
  364. <td>baz</td>
  365. <td>bim</td>
  366. </tr>
  367. </tbody>
  368. </table>