sample.my.ast (10109B)
1 .document 2 .heading 3 .marker 4 "#" 5 .text 6 "Mymarkdown syntax showcase" 7 .paragraph 8 .text 9 "@@ $toc.generate()" 10 .heading 11 .marker 12 "##" 13 .text 14 "Block syntaxes" 15 .heading 16 .marker 17 "###" 18 .text 19 "Paragraphs" 20 .paragraph 21 .text 22 "Normal blocks of text separated by newlines, constitute paragraphs." 23 .space_text 24 "This sentence is part of the same paragraph as above." 25 .paragraph 26 .text 27 "While the first line of a paragraph may not be indented," 28 .space_text 29 " subsequent lines may be indented relative to the first line." 30 .quote 31 .paragraph 32 .text 33 "This is a paragraph." 34 .paragraph 35 .error .inconsistent_indentation at 17:3 36 .text 37 "This is a syntax error." 38 .paragraph 39 .text 40 "In general, indented blocks are not allowed unless explicitly introduced by a marker." 41 .space_text 42 "In particular, indented code blocks do not exist in mymarkdown." 43 .space_text 44 "This is because indented blocks can easily arise from having insufficient indentation on the previous element." 45 .paragraph 46 .text 47 "Paragraphs may also be introduced with the `;` marker," 48 .space_text 49 "similar to other block syntaxes." 50 .space_text 51 "An indented set of blocks follows the `;` marker." 52 .heading 53 .marker 54 "###" 55 .text 56 "Headings" 57 .paragraph 58 .text 59 "Headings are introduced with hashes." 60 .space_text 61 "The number of hashes indicates the level of the heading (h1 = `#`, h2 = `##`, ...)." 62 .space_text 63 "A single indented inline block follows the marker." 64 .paragraph 65 .text 66 "Note that indented blocks in mymarkdown are strict ---" 67 .space_text 68 "the first non-whitespace character after the marker is used to determine the indentation," 69 .space_text 70 "after which all subsequent lines must have matching or more indentation." 71 .quote 72 .heading 73 .marker 74 "####" 75 .text 76 "This is a" 77 .space_text 78 "multiline heading." 79 .heading 80 .marker 81 "####" 82 .text 83 "This is also a" 84 .space_text 85 " multiline heading." 86 .heading 87 .marker 88 "####" 89 .text 90 "This is a syntax error." 91 .space_text 92 .error .unexpected_block_in_inline_context 93 "This is because there are two paragraphs following the marker." 94 .heading 95 .marker 96 "####" 97 .text 98 "This heading itself is not a syntax error." 99 .space_text 100 .error .inconsistent_indentation at 48:5 101 "But this misaligned second line is interpreted as an indented paragraph, which is a syntax error." 102 .heading 103 .marker 104 "###" 105 .text 106 "Blocks" 107 .quote 108 .paragraph 109 .text 110 "Blocks are introduced by the `>` marker." 111 .paragraph 112 .text 113 "An indented set of blocks follows the `>` marker." 114 .quote 115 .paragraph 116 .text 117 "Unlike markdown, placing `>` before each line is probably a mistake." 118 .quote 119 .paragraph 120 .text 121 "This is because each `>` introduces a new block quote, making this the third blockquote in this section." 122 .heading 123 .marker 124 "###" 125 .text 126 "Lists" 127 .paragraph 128 .text 129 "There are many types of lists in mymarkdown. They are:" 130 .list 131 .unordered_item 132 .marker 133 "-" 134 .text 135 "Unordered list, introduced by `-`" 136 .unordered_item 137 .marker 138 "-" 139 .text 140 "Ordered list, introduced by `.`" 141 .unordered_item 142 .marker 143 "-" 144 .text 145 "Description list, introduced by `:`" 146 .unordered_item 147 .marker 148 "-" 149 .text 150 "Task list, introduced by `- [ ]`, `- [x]`, or `- [X]`" 151 .paragraph 152 .text 153 "In all cases, the list is formed by grouping list items of the same marker type," 154 .space_text 155 "and an indented inline block follows the list item marker." 156 .paragraph 157 .text 158 "The level of nesting can be increased by repeating the marker:" 159 .list 160 .unordered_item 161 .marker 162 "-" 163 .text 164 "Level-2 unordered list marker: `--`" 165 .unordered_item 166 .marker 167 "-" 168 .text 169 "Level-2 ordered list marker: `..`" 170 .unordered_item 171 .marker 172 "-" 173 .text 174 "Level-2 description list marker: `::`" 175 .unordered_item 176 .marker 177 "-" 178 .text 179 "Level-2 task list marker: `-- [ ]`, `-- [x]`, or `-- [X]`" 180 .paragraph 181 .text 182 "Note that for ordered lists, no numbers or letters are allowed before the marker." 183 .space_text 184 "Instead they are simply automatically numbered from 1." 185 .space_text 186 "Use directives to adjust the starting index." 187 .paragraph 188 .text 189 "Nested labels extend the parent's counter rather than beginning a new counter." 190 .list 191 .ordered_item 192 .marker 193 "." 194 .text 195 "List item 1" 196 .ordered_item 197 .marker 198 "." 199 .text 200 "List item 2" 201 .ordered_item 202 .marker 203 ".." 204 .text 205 "List item 2.1" 206 .ordered_item 207 .marker 208 ".." 209 .text 210 "List item 2.2" 211 .ordered_item 212 .marker 213 "." 214 .text 215 "List item 3" 216 .paragraph 217 .text 218 "For all list items, an indented //inline// block follows the list marker," 219 .space_text 220 "**not** an arbitrary **set** of indented blocks." 221 .space_text 222 "That means the following is a syntax error:" 223 .quote 224 .list 225 .unordered_item 226 .marker 227 "-" 228 .text 229 "This is a syntax error." 230 .space_text 231 .error .unexpected_block_in_inline_context 232 "One should not use multiple paragraphs in a list item." 233 .paragraph 234 .text 235 "To have items that contain multiple paragraphs, instead use a short phrase or sentence for the list item itself," 236 .space_text 237 "and follow it up with a longer series of paragraphs that [//elaborate//](#List item elaborations) on the list item." 238 .heading 239 .marker 240 "###" 241 .text 242 "List item elaborations" 243 .paragraph 244 .text 245 "Sometimes, lists are used not to convey merely a list of items," 246 .space_text 247 "but also come with a **elaboration** or **description** of the item." 248 .space_text 249 "In such cases, elaboration blocks introduced by `+` markers matching the level of the list item" 250 .space_text 251 "can be added immediately after the list item to be described or elaborated on." 252 .space_text 253 "This way, the main list marker itself can be used to contain just the key point or phrase." 254 .paragraph 255 .text 256 "An indented set of blocks follows the list item elaboration marker." 257 .heading 258 .marker 259 "####" 260 .text 261 "Examples" 262 .list 263 .unordered_item 264 .marker 265 "-" 266 .text 267 "Some examples of when list item elaborations can be used:" 268 .unordered_item 269 .marker 270 "--" 271 .text 272 "**In a list of pros and cons.**" 273 .elaboration 274 .marker 275 "++" 276 .paragraph 277 .text 278 "The main list items can be used to list the actual pros and cons," 279 .space_text 280 "while list item elaborations can be used to justify them." 281 .unordered_item 282 .marker 283 "--" 284 .text 285 "**In a list of examples.**" 286 .elaboration 287 .marker 288 "++" 289 .paragraph 290 .text 291 "The main list items can be used for the names of the examples," 292 .space_text 293 "while elaborations go into more detail about how the examples work." 294 .space_text 295 "Like this example!" 296 .unordered_item 297 .marker 298 "-" 299 .text 300 "Some examples of when list item elaborations must be used:" 301 .unordered_item 302 .marker 303 "--" 304 .text 305 "**When you want to nest multiple paragraphs within a bullet.**" 306 .elaboration 307 .marker 308 "++" 309 .paragraph 310 .text 311 "As the list item markers themselves only take in one indented inline block," 312 .space_text 313 "they physically cannot contain multiple paragraphs." 314 .space_text 315 "This limitation is meant to discourage using lists in situations" 316 .space_text 317 "where a subsection would be more appropriate." 318 .paragraph 319 .text 320 "In such cases, it is usually beneficial to add a short \"name\" or \"title\" for your paragraphs" 321 .space_text 322 "in the actual list item (and emphasize or strongly emphasize them)," 323 .space_text 324 "and then place the paragraphs themselves inside the list item elaboration." 325 .paragraph 326 .text 327 "If that is not desirable however, the workaround is to use an //empty// list item," 328 .space_text 329 "so that the paragraphs you place inside the list item elaboration" 330 .space_text 331 "become the only paragraphs nested under the bullet." 332 .unordered_item 333 .marker 334 "-" 335 .text 336 "Some examples of when list item elaborations should not be used:" 337 .unordered_item 338 .marker 339 "--" 340 .text 341 "**When you simply have long list items.**" 342 .elaboration 343 .marker 344 "++" 345 .paragraph 346 .text 347 "Regardless of the length of the content you wish to place in the list items," 348 .space_text 349 "the key consideration to keep in mind is whether the content \"belongs\" to the main list," 350 .space_text 351 "or simply to the current list item." 352 .paragraph 353 .text 354 "If the content does truly belong to the main list, then the content should be used as the list item itself." 355 .space_text 356 "In such cases, it may be worth making the list a //loose// list, which means placing empty lines after each list item."