asciidoc-parser 0.19.0

Parser for AsciiDoc format
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
538
539
540
541
542
use crate::tests::prelude::*;

track_file!("ref/asciidoc-lang/docs/modules/ROOT/pages/asciidoc-vs-markdown.adoc");

non_normative!(
    r#"
= Compare AsciiDoc to Markdown
:description: A brief, side-by-side comparison of AsciiDoc and Markdown.

The most compelling reason to choose a lightweight markup language for writing is to minimize the number of technical concepts an author must grasp in order to be immediately productive.
In other words, the goal is to be able to _write without friction_.
While that's certainly the goal of both AsciiDoc and Markdown, and both are very approachable for newcomers, this page explores why AsciiDoc is a more suitable alternative to Markdown as your content grows and evolves.

== Starting with Markdown

The most prevalent lightweight markup language is Markdown.
(At least, Markdown is what you call it at first).
The main advantage of Markdown lies in its primitive syntax: its manual and cheatsheet are one and the same.
But this advantage is also its greatest weakness.

As soon as authors need something slightly more complex than basic prose (e.g., tables, cross references, footnotes, embedded YouTube videos, etc.), they find themselves resorting to embedded HTML or seeking out more feature-rich implementations.
Markdown has become a maze of different implementations, termed "`flavors`", which make a universal definition evasive.

NOTE: The IETF has declared "`there is no such thing as "invalid" Markdown.`"
See https://tools.ietf.org/html/rfc7763#section-1.1[This Is Markdown! Or: Markup and Its Discontents^].

Here's how the story inevitably goes.
You start out with Markdown.
Then it's Markdown + X.
Then Markdown + X + Y.
And down the rabbit hole you go.
What's worse, X and Y often require you to sprinkle in HTML, unnecessarily coupling content with presentation and wrecking portability.
Your instinct to choose Markdown is good.
There are just better options.

== Graduating to AsciiDoc

AsciiDoc presents a more sound alternative.
The AsciiDoc syntax is more concise than (or at least as concise as) Markdown.
At the same time, AsciiDoc offers power and flexibility without requiring the use of HTML or "`flavors`" for essential syntax such as tables, description lists, admonitions (tips, notes, warnings, etc.) and table of contents.

It's important to understand that AsciiDoc was initially designed as a plain-text alternative to the DocBook XML schema.
AsciiDoc isn't stuck in a game of whack-a-mole trying to satisfy publishing needs like Markdown.
Rather, the AsciiDoc syntax was explicitly designed with the needs of publishing in mind, both print and web.
If the need arises, you can make full use of the huge choice of tools available for a DocBook workflow using Asciidoctor's DocBook converter.
That's why mapping to an enterprise documentation format like DocBook remains a key use case for AsciiDoc.

And yet, AsciiDoc is simple enough to stand in as a better flavor of Markdown.
But what truly makes AsciiDoc the right investment is that its syntax was designed to be extended as a core feature.
This extensibility not only means that AsciiDoc has a lot more to offer, with room to grow, it also fulfills the objective of ensuring your content is maximally reusable.

== Comparison by example

The following table shows the AsciiDoc syntax as it compares to Markdown.
Since AsciiDoc supports a broader range of syntax than Markdown, this side-by-side comparison focuses mainly on areas where the syntax overlaps.

.A selection of AsciiDoc language features compared to Markdown
[#asciidoc-vs-markdown%autowidth]
|===
|Language Feature |Markdown |AsciiDoc

|Bold (constrained)
a|
[source,markdown]
----
**bold**
----
a|
[source]
----
*bold*
----

|Bold (unconstrained)
a|
[source,markdown]
----
**b**old
----
a|
[source]
----
**b**old
----

|Italic (constrained)
a|
[source,markdown]
----
*italic*
----
a|
[source]
----
_italic_
----

|Italic (unconstrained)
|_n/a_
a|
[source]
----
__i__talic
----

|Monospace (constrained)
a|
[source,markdown]
----
`monospace`
----
a|
[source]
----
`monospace`
----

|Monospace (unconstrained)
a|
[source,markdown]
----
`m`onospace
----
a|
[source]
----
``m``onospace
----

|Literal monospace
a|
[source,markdown]
----
`http://localhost:8080`
`/issue/{id}`
----
a|
[source]
----
`+http://localhost:8080+`
`+/issue/{id}+`
----

|Link with label
a|
[source,markdown]
----
[Asciidoctor](https://asciidoctor.org)
----
a|
[source]
----
https://asciidoctor.org[Asciidoctor]
----

|Relative link
a|
[source,markdown]
----
[user guide](user-guide.html)
----
a|
[source]
----
link:user-guide.html[user guide]
xref:user-guide.adoc[user guide]
----

|File link
a|
[source,markdown]
----
[get the PDF]({% raw %}{{ site.url }}{% endraw %}/assets/mydoc.pdf)
----
a|
[source]
----
link:{site-url}/assets/mydoc.pdf[get the PDF]
----

|Cross reference
a|
[source,markdown]
----
See [Usage](#_usage).

<h2 id="_usage">Usage</h2>
----
a|
[source]
----
See <<_usage>>.

== Usage
----

|Block ID (aka anchor)
a|
[source,markdown]
----
<h2 id="usage">Usage</h2>
----
a|
[source]
----
[#usage]
== Usage
----

|Inline anchor
|_n/a_
a|
[source]
----
. [[step-1]]Download the software
----

|Inline image w/ alt text
a|
[source,markdown]
----
![Logo](/images/logo.png)
----
a|
[source]
----
image:logo.png[Logo]
----

|Block image w/ alt text
|_n/a_
a|
[source]
----
image::logo.png[Logo]
----

|Section heading*
a|
[source,markdown]
----
## Heading 2
----
a|
[source]
----
== Heading 2
----

|Blockquote*
a|
[source,markdown]
----
> Quoted text.
>
> Another paragraph in quote.
----
a|
[source]
----
____
Quoted text.

Another paragraph in quote.
____
----

|Literal block
a|
[source,markdown]
----
    $ gem install asciidoctor
----
a|
.Indented (by 1 or more spaces)
[source]
----
 $ gem install asciidoctor
----

.Delimited
[source]
----
....
$ gem install asciidoctor
....
----

|Code block*
a|
[source,markdown]
----
```java
public class Person {
  private String name;
  public Person(String name) {
    this.name = name;
  }
}
```
----
a|
[source]
....
[source,java]
----
public class Person {
  private String name;
  public Person(String name) {
    this.name = name;
  }
}
----
....

|Unordered list
a|
[source,markdown]
----
* apples
* orange
  * temple
  * navel
* bananas
----
a|
[source]
----
* apples
* oranges
** temple
** navel
* bananas
----
|Ordered list
a|
[source,markdown]
----
1. first
2. second
3. third
----
a|
[source]
----
. first
. second
. third
----

|Thematic break (aka horizontal rule)*
a|
[source,markdown]
----
***

* * *

---

- - -

___

_ _ _
----
a|
[source]
----
'''
----

|Typographic quotes (aka "`smart quotes`")
|Enabled through an extension switch, but offer little control in how they are applied.
a|
[source]
----
The `'90s popularized a new form of music known as "`grunge`" rock.
It'll turn out to have an impact that extended well beyond music.
----

|Document header
a|
.Slapped on as "`front matter`"
[source,markdown]
----
---
layout: docs
title: Writing posts
prev_section: defining-frontmatter
next_section: creating-pages
permalink: /docs/writing-posts/
---
----
a|
.Native support!
[source]
----
= Writing posts
:page-layout: base
:showtitle:
:prev_section: defining-frontmatter
:next_section: creating-pages
----

|Admonitions
|_n/a_
a|
[source]
----
TIP: You can add line numbers to source listings by adding the word `numbered` in the attribute list after the language name.
----

|Sidebars
|_n/a_
a|
[source]
----
.Lightweight Markup
****
Writing languages that let you type less and express more.
****
----

|Block titles
|_n/a_
a|
[source]
----
.Grocery list
* Milk
* Eggs
* Bread
----

|Includes
|_n/a_
a|
[source]
----
\include::intro.adoc[]
----

|URI reference
a|
[source,markdown]
----
Go to the [home page][home].

[home]: https://example.org
----
a|
[source]
----
:home: https://example.org

Go to the {home}[home page].
----

|Custom CSS classes
|_n/a_
a|
[source]
----
[.path]_Gemfile_
----
|===

+*+ Asciidoctor also supports the Markdown syntax for this language feature.

You can see that AsciiDoc has the following advantages over Markdown:

* AsciiDoc uses the same number of markup characters or less when compared to Markdown in nearly all cases.
* AsciiDoc uses a consistent formatting scheme (i.e., it has consistent patterns).
* AsciiDoc can handle all permutations of nested inline (and block) formatting, whereas Markdown often falls down.
* AsciiDoc handles cases that Markdown doesn't, such as a proper approach to inner-word markup, source code blocks and block-level images.

NOTE: Certain Markdown flavors, such as Markdown Extra, support additional features such as tables and description lists.
However, since these features don't appear in "`plain`" Markdown, they're not included in the comparison table.
But they're supported natively by AsciiDoc.

Asciidoctor, which is used for converting AsciiDoc on GitHub and GitLab, emulates some of the common parts of the Markdown syntax, like headings, blockquotes and fenced code blocks, simplifying the migration from Markdown to AsciiDoc.
For details, see xref:syntax-quick-reference.adoc#markdown-compatibility[Markdown compatibility].

////
===== Description Lists in AsciiDoc

[source]
----
a term:: a description
another term:: another description
----

They can even hold code examples:

[source]
....
term with code example:: a description
+
[source,java]
----
public class Person {
}
----
....

===== Tables in AsciiDoc

An AsciiDoc table can be written as a series of lists which use a vertical bar as the list marker:

[source]
----
[cols=3]
|===
|a
|b
|c

|1
|2
|3
|===
----

Which appears as:

[cols=3]
|===
|a
|b
|c

|1
|2
|3
|===

Markdown Extra supports tables and description lists, too; but it's not Markdown.
Also, unlike Markdown Extra, AsciiDoc can apply formatting to cells.
////
"#
);