markdoll 4.1.2

a structured and extensible markup language
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
---
awawa!
---

this is markdoll

markdoll is an extensible markup language written in rust, made: by dolls, for dolls

&how is it different from other markup languages?
	like HTML, markdoll is a tree shaped system. for example, headers always precede sections,
	which have a defined ending point, an explicit hierarchy, rather than an implicit one
&specification
	&whitespace
		in markdoll, tab characters are significant, they help define sections and lists, and provide a boundary for block-content tags

		markdoll specifically does [em:not] assign importance to spaces, but does prohibit them in certain cases

		newlines are also very signficant:

		-	unless the last character of the line is a backslash ([code:\\]), splitting text by a newline instead inserts a space
		-	separating text/tags by an empty line splits it into two paragraphs
		-	separating list elements by an empty line splits it into two lists

		[em(h):do note that all .doll files must be LF, CR characters will cause a fatal parsing error]
	&tags
		markdoll has a concept of "tags", which have a keyword and may choose to have arguments and content

		tags can be written multiple ways:
		[table::
			=	=	kind
				=	syntax
				=	description

			-	=	no-arg & no-content
				-	[codeblock::
						[sometag]
					]
				-	invokes [code:sometag], does not provide an argument or any content

			-	=	arg & no-content
				-	[codeblock::
						[sometag(argument that can have any non-parenthesis tokens in it)]
					]
				-	invokes [code:sometag], providing the argument text, but no content

			-	=	no-arg & content
				-	[codeblock::
						[sometag:content]
						[sometag::
							block content
						]
					]
				-	invokes [code:sometag], does not provide an argument, but provides content[ref(block-tags)]

			-	=	arg & content
				-	[codeblock::
						[sometag(argument that can have any non-parenthesis tokens in it):content]
						[sometag(argument that can have any non-parenthesis tokens in it)::
							block content
						]
					]
				-	invokes [code:sometag], providing an argument and content[ref(block-tags)]
		]

		[def(block-tags)::
			block tags allow far more flexibility in the content of tags, being able to put anything inside of them,
			without markdoll interpreting it whatsoever, leaving that to that tag (including escape sequences!)

			however, this requires that the content is indented one level further than the tag, to let the parser know what is and is not part of the content
		]
	&escape sequences
		most parts of markdoll support escape sequences with the backslash character ([code:\\])

		for example:
		-	[code:[em:\\\]]] results in: [em:\]]
		-	[code:[em:\\\\]] results in: [em:\\\\]

		inline tags do not need to escape [em:balanced] square brackets, however
		-	[code:[em:]\]] is [em:unbalanced] and will end early
		-	[code:[em:[]]] is [em:balanced] and will not end early

		block tags completely ignore escaping/balancing, their content is fed as-is into the tag, after the indentation of the tag + 1 has been stripped.
		they dont have to care about escaping/balancing because the only way to terminate them is to lower the indentation again, which isnt something that could be escaped
	&lists
		unordered and ordered lists are also easy:

		[table::
			=	=	kind
				=	syntax
				=	result

			-	=	unordered
				-	[codeblock::
						-	single line
						-	[em:can also include formatting]
						-	lists can also
							span multiple lines
							if the same indent is kept
					]
				-	-	single line
					-	[em:can also include formatting]
					-	lists can also
						span multiple lines
						if the same indent is kept

			-	=	ordered
				-	[codeblock::
						=	single line
						=	[em:can also include formatting]
						=	lists can also
							span multiple lines
							if the same indent is kept
					]
				-	=	single line
					=	[em:can also include formatting]
					=	lists can also
						span multiple lines
						if the same indent is kept
		]
	&sections
		a section is preceded by a heading, and its content is indented 1 level higher

		[table::
			=	=	syntax
				=	result

			-	-	[codeblock::
						&hello
							&world
								content
							goes
						here
					]
				-	&hello
						&world
							content
						goes
					here
		]

		when emitting to HTML, it is not recommended to have more than one top-level section,
		as multiple h1 elements causes accessibility issues
	&frontmatter
		markdoll differentiates between parsing as a [em:document] and everything else:
		-	each tag parses its content as embedded markdoll source via [code:parse_embedded], so frontmatter would not be parsed in these situations
		-	but when parsing a main document via [code:parse_document], frontmatter is permitted.

		frontmatter works almost identically to the way it does in many other markup languages,
		with an optional section at the very beginning of a file that is fenced with [code:---]:

		[codeblock::
			---
			whatever
			---

			normal content goes here
		]

		while some languages choose to parse frontmatter as [link(https://yaml.org/):YAML] or [link(https://toml.io/):TOML],
		markdoll does not wish to take part in the war between the two, and just returns it as a string
&extensibility
	markdoll and its standard library emits HTML by default, but it doesn't have to!

	markdoll does not load [em:any] tags automatically, all of them must be manually inserted.
	the standard library all supports HTML by default, and can be extended with other targets

	&standard extensions
		the standard library is in the [code:markdoll::ext] module

		&common
			in module [code:markdoll::ext::common]

			[table::
				=	=	tag
					=	description
					=	syntax
					=	result

				-	=	[code://]
					-	the comment tag is very simple, its content is not parsed and is excluded from the output
					-	[codeblock::
							[//:this will not be included in the output]
						]
					-	[//:this will not be included in the output]
			]
		&formatting
			in module [code:markdoll::ext::formatting]

			[table::
				=	=	tag
					=	description
					=	syntax
					=	result

				-	[tc(head)(rows=8):[code:em]]
					[tc(rows=8)::
						apply one or more forms of emphasis to the content

						flags:
						-	i\
							italics\
							[em:default if no flags are specified]
						-	b\
							bold
						-	u\
							underline
						-	s\
							strikethrough
						-	h\
							highlight
						-	q\
							quote
					]
					-	[codeblock:[em:italics]]
					-	[em:italics]
				-	-	[codeblock:[em(i):italics (explicit)]]
					-	[em(i):italics (explicit)]
				-	-	[codeblock:[em(b):bold]]
					-	[em(b):bold]
				-	-	[codeblock:[em(u):underline]]
					-	[em(u):underline]
				-	-	[codeblock:[em(s):strikethrough]]
					-	[em(s):strikethrough]
				-	-	[codeblock:[em(h):highlight]]
					-	[em(h):highlight]
				-	-	[codeblock:[em(q):quote]]
					-	[em(q):quote]
				-	-	[codeblock:[em(i)(b)(u)(s)(h)(q):everything]]
					-	[em(i)(b)(u)(s)(h)(q):everything]

				-	[tc(head)(rows=2):[code:quote]]
					[tc(rows=2)::
						block quotes

						an optional cite argument may be provided
					]
					-	[codeblock::
							[quote::
								block quotes can contain [em:markdoll]
							]
						]
					-	[quote::
							block quotes can contain [em:markdoll]
						]
				-	-	[codeblock::
							[quote(citation goes here)::
								block quotes can contain [em:markdoll]
							]
						]
					-	[quote(citation goes here)::
							block quotes can contain [em:markdoll]
						]
			]
		&code
			in module [code:markdoll::ext::code]

			[table::
				=	=	tag
					=	description
					=	syntax
					=	result

				-	=	[code:code]
					-	inline code blocks
					-	[codeblock:[code:whatever code goes here, it is not [parsed]]]
					-	[code:whatever code goes here, it is not [parsed]]

				-	=	[code:codeblock]
					-	multi-line code blocks
					-	[codeblock::
							[codeblock::
								anything can go here :3
							]
						]
					-	[codeblock::
							anything can go here :3
						]
			]
		&links
			in module [code:markdoll::ext::links]

			[table::
				=	=	tag
					=	description
					=	syntax
					=	result

				-	=	[code:link]
					-	link to content
					-	[codeblock:[link(https://codeberg.org/0x57e11a/markdoll):markdoll]]
					-	[link(https://codeberg.org/0x57e11a/markdoll):markdoll]

				-	=	[code:img]
					-	insert images
					-	[codeblock::
							[img(https://codeberg.org/0x57e11a/markdoll/raw/branch/main/button.png)::
								alt text goes here (88x31 button that says MADE WITH MARKDOLL)
							]
						]
					-	[img(https://codeberg.org/0x57e11a/markdoll/raw/branch/main/button.png)::
							alt text goes here (88x31 button that says MADE WITH MARKDOLL)
						]

				-	=	[code:anchor]
					-	invisible anchors to be used with the [code:ref] tag (ideal for section heads)
					-	[codeblock:[anchor(anchor-tag)]]
					-	[anchor(anchor-tag)]

				-	=	[code:def]
					-	in-page anchors to be used with the [code:ref] tag
					-	[codeblock:[def(def-tag):some definition]]
					-	[def(def-tag):some definition]

				-	=	[code:ref]
					-	link to an anchor defined by the [code:def] tag
					-	[codeblock:this is a reference[ref(def-tag)][ref(anchor-tag)]]
					-	this is a reference[ref(def-tag)][ref(anchor-tag)]
			]
		&table
			in module [code:markdoll::ext::table]

			[table::
				=	=	tag
					=	description
					=	syntax
					=	result

				-	[tc(head)(rows=2):[code:table]]
					[tc(rows=2)::
						tables

						tables have two syntaxes (that can be mix-matched, even within eachother):
						-	list syntax

							unordered list elements define normal rows/cells, ordered lists define head rows/cells\
							[em:cannot create cells that span multiple rows/columns, use tags for that]
						-	tag syntax

							using [code:tr]/[code:tc] tags and their arguments/flags
					]
					-	[codeblock::
							[table::
								=	=	r1c1
									=	r1c2
									=	r1c3

								-	=	r2c1
									-	r2c2
									-	r2c3

								-	=	r3c1
									-	r3c2
									-	r3c3
							]
						]
					-	[table::
							=	=	r1c1
								=	r1c2
								=	r1c3

							-	=	r2c1
								-	r2c2
								-	r2c3

							-	=	r3c1
								-	r3c2
								-	r3c3
						]
				-	-	[codeblock::
							[table::
								[tr(head)::
									[tc(head):r1c1]
									[tc(head):r1c2]
									[tc(head):r1c3]
								]

								[tr::
									[tc(head):r2c1]
									[tc:r2c2]
									[tc:r2c3]
								]

								[tr::
									[tc(head):r3c1]
									[tc:r3c2]
									[tc:r3c3]
								]
							]
						]
					-	[table::
							[tr(head)::
								[tc(head):r1c1]
								[tc(head):r1c2]
								[tc(head):r1c3]
							]

							[tr::
								[tc(head):r2c1]
								[tc:r2c2]
								[tc:r2c3]
							]

							[tr::
								[tc(head):r3c1]
								[tc:r3c2]
								[tc:r3c3]
							]
						]

				-	[tc(head)(rows=2):[code:tr]]
					[tc(rows=2)::
						create table rows inside tables

						pass the [code:head] flag to insert it into the head section
					]
					-	[codeblock::
							[table::
								[tr::
									[tc:cells go here, whether by list or tag syntax]
								]
							]
						]
					-	[table::
							[tr::
								[tc:cells go here, whether by list or tag syntax]
							]
						]
				-	-	[codeblock::
							[table::
								[tr(head)::
									[tc(head)::
										cells go here, they should be [code:head] cells,
										whether by list or tag syntax
									]
								]
							]
						]
					-	[table::
							[tr(head)::
								[tc(head)::
									cells go here, they should be [code:head] cells,
									whether by list or tag syntax
								]
							]
						]

				-	[tc(head)(rows=4):[code:tc]]
					[tc(rows=4)::
						create table cells inside table rows

						pass the [code:head] flag to make it a head cell

						set the [code:rows]/[code:cols] props to make cells that span multiple rows/columns
					]
					-	[codeblock::
							[table::
								[tr::
									[tc:content]
								]
							]
						]
					-	[table::
							[tr::
								[tc:content]
							]
						]
				-	-	[codeblock::
							[table::
								[tr::
									[tc(head):content]
								]
							]
						]
					-	[table::
							[tr::
								[tc(head):content]
							]
						]
				-	-	[codeblock::
							[table::
								[tr::
									[tc(rows=2):two rows]
									[tc:upper]
								]
								[tr::
									[tc:lower]
								]
							]
						]
					-	[table::
							[tr::
								[tc(rows=2):two rows]
								[tc:upper]
							]
							[tr::
								[tc:lower]
							]
						]
				-	-	[codeblock::
							[table::
								[tr::
									[tc(cols=2):two cols]
								]
								[tr::
									[tc:left]
									[tc:right]
								]
							]
						]
					-	[table::
							[tr::
								[tc(cols=2):two cols]
							]
							[tr::
								[tc:left]
								[tc:right]
							]
						]
			]
	&danger zone
		by enabling the crate feature [code:danger], the [code:ext::danger] module becomes available for use, and is automatically loaded into the default binary

		this contains potentially dangerous tags, proceed with caution

		[table::
			=	=	tag
				=	description
				=	syntax

			-	=	[code:invoke]
				-	invoke an external command, passing arguments as cli args, content as stdin, dumping stdout into the output stream
				-	[codeblock::
						[invoke(./test.sh)(flip):hello world]
					]
					[em:imagine [code:test.sh] sees the [code:flip] argument and returns a version of stdin with all the letters flipped around]
		]
[link(https://codeberg.org/0x57e11a/markdoll):[img(https://codeberg.org/0x57e11a/markdoll/raw/branch/main/button.png):MADE WITH MARKDOLL]]