syntax.adoc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. = AsciiDoc Syntax
  2. :icons: font
  3. :stem:
  4. :toc: left
  5. :url-docs: https://asciidoctor.org/docs
  6. :url-gem: https://rubygems.org/gems/asciidoctor
  7. A brief reference of the most commonly used AsciiDoc syntax.
  8. You can find the full documentation for the AsciiDoc syntax at {url-docs}.
  9. == Paragraphs
  10. A normal paragraph.
  11. Line breaks are not preserved.
  12. // line comments, which are lines that start with //, are skipped
  13. A blank line separates paragraphs.
  14. [%hardbreaks]
  15. This paragraph carries the `hardbreaks` option.
  16. Notice how line breaks are now preserved.
  17. An indented (literal) paragraph disables text formatting,
  18. preserves spaces and line breaks, and is displayed in a
  19. monospaced font.
  20. [sidebar#id.role]
  21. A style, ID, and/or role gives a paragraph (or block) special meaning, like this sidebar.
  22. NOTE: An admonition paragraph, like this note, grabs the reader's attention.
  23. TIP: Convert this document using the `asciidoctor` command to see the output produced from it.
  24. == Text Formatting
  25. :hardbreaks:
  26. .Constrained (applied at word boundaries)
  27. *strong importance* (aka bold)
  28. _stress emphasis_ (aka italic)
  29. `monospaced` (aka typewriter text)
  30. "`double`" and '`single`' typographic quotes
  31. +passthrough text+ (substitutions disabled)
  32. `+literal text+` (monospaced with substitutions disabled)
  33. .Unconstrained (applied anywhere)
  34. **C**reate+**R**ead+**U**pdate+**D**elete
  35. fan__freakin__tastic
  36. ``mono``culture
  37. .Replacements
  38. A long time ago in a galaxy far, far away...
  39. (C) 1976 Arty Artisan
  40. I believe I shall--no, actually I won't.
  41. .Macros
  42. // where c=specialchars, q=quotes, a=attributes, r=replacements, m=macros, p=post_replacements, etc.
  43. The European icon:flag[role=blue] is blue & contains pass:[************] arranged in a icon:circle-o[role=yellow].
  44. The pass:c[->] operator is often referred to as the stabby lambda.
  45. Since `pass:[++]` has strong priority in AsciiDoc, you can rewrite pass:c,a,r[C++ => C{pp}].
  46. // activate stem support by adding `:stem:` to the document header
  47. stem:[sqrt(4) = 2]
  48. :!hardbreaks:
  49. == Attributes
  50. // define attributes in the document header; must be flush with left margin
  51. :name: value
  52. You can download and install Asciidoctor {asciidoctor-version} from {url-gem}.
  53. C{pp} is not required, only Ruby.
  54. Use a leading backslash to output a word enclosed in curly braces, like \{name}.
  55. == Links
  56. [%hardbreaks]
  57. https://example.org/page[A webpage]
  58. link:../path/to/file.txt[A local file]
  59. xref:document.adoc[A sibling document]
  60. mailto:hello@example.org[Email to say hello!]
  61. == Anchors
  62. [[idname,reference text]]
  63. // or written using normal block attributes as `[#idname,reftext=reference text]`
  64. A paragraph (or any block) with an anchor (aka ID) and reftext.
  65. See <<idname>> or <<idname,optional text of internal link>>.
  66. xref:document.adoc#idname[Jumps to anchor in another document].
  67. This paragraph has a footnote.footnote:[This is the text of the footnote.]
  68. == Lists
  69. === Unordered
  70. * level 1
  71. ** level 2
  72. *** level 3
  73. **** level 4
  74. ***** etc.
  75. * back at level 1
  76. +
  77. Attach a block or paragraph to a list item using a list continuation (which you can enclose in an open block).
  78. .Some Authors
  79. [circle]
  80. - Edgar Allen Poe
  81. - Sheri S. Tepper
  82. - Bill Bryson
  83. === Ordered
  84. . Step 1
  85. . Step 2
  86. .. Step 2a
  87. .. Step 2b
  88. . Step 3
  89. .Remember your Roman numerals?
  90. [upperroman]
  91. . is one
  92. . is two
  93. . is three
  94. === Checklist
  95. * [x] checked
  96. * [ ] not checked
  97. === Callout
  98. // enable callout bubbles by adding `:icons: font` to the document header
  99. [,ruby]
  100. ----
  101. puts 'Hello, World!' # <1>
  102. ----
  103. <1> Prints `Hello, World!` to the console.
  104. === Description
  105. first term:: description of first term
  106. second term::
  107. description of second term
  108. == Document Structure
  109. === Header
  110. // header must be flush with left margin
  111. = Document Title
  112. Author Name <author@example.org>
  113. v1.0, 2019-01-01
  114. === Sections
  115. // must be flush with left margin
  116. = Document Title (Level 0)
  117. == Level 1
  118. === Level 2
  119. ==== Level 3
  120. ===== Level 4
  121. ====== Level 5
  122. == Back at Level 1
  123. === Includes
  124. // must be flush with left margin
  125. include::basics.adoc[]
  126. // define -a allow-uri-read to allow content to be read from URI
  127. include::https://example.org/installation.adoc[]
  128. == Blocks
  129. --
  130. open - a general-purpose content wrapper; useful for enclosing content to attach to a list item
  131. --
  132. // recognized types include CAUTION, IMPORTANT, NOTE, TIP, and WARNING
  133. // enable admonition icons by setting `:icons: font` in the document header
  134. [NOTE]
  135. ====
  136. admonition - a notice for the reader, ranging in severity from a tip to an alert
  137. ====
  138. ====
  139. example - a demonstration of the concept being documented
  140. ====
  141. .Toggle Me
  142. [%collapsible]
  143. ====
  144. collapsible - these details are revealed by clicking the title
  145. ====
  146. ****
  147. sidebar - auxiliary content that can be read independently of the main content
  148. ****
  149. ....
  150. literal - an exhibit that features program output
  151. ....
  152. ----
  153. listing - an exhibit that features program input, source code, or the contents of a file
  154. ----
  155. [,language]
  156. ----
  157. source - a listing that is embellished with (colorized) syntax highlighting
  158. ----
  159. ```language
  160. fenced code - a shorthand syntax for the source block
  161. ```
  162. [,attribution,citetitle]
  163. ____
  164. quote - a quotation or excerpt; attribution with title of source are optional
  165. ____
  166. [verse,attribution,citetitle]
  167. ____
  168. verse - a literary excerpt, often a poem; attribution with title of source are optional
  169. ____
  170. ++++
  171. pass - content passed directly to the output document; often raw HTML
  172. ++++
  173. // activate stem support by adding `:stem:` to the document header
  174. [stem]
  175. ++++
  176. x = y^2
  177. ++++
  178. ////
  179. comment - content which is not included in the output document
  180. ////
  181. == Tables
  182. .Table Attributes
  183. [cols=>1h;2d,width=50%,frame=topbot]
  184. |===
  185. | Attribute Name | Values
  186. | options
  187. | header,footer,autowidth
  188. | cols
  189. | colspec[;colspec;...]
  190. | grid
  191. | all \| cols \| rows \| none
  192. | frame
  193. | all \| sides \| topbot \| none
  194. | stripes
  195. | all \| even \| odd \| none
  196. | width
  197. | (0%..100%)
  198. | format
  199. | psv {vbar} csv {vbar} dsv
  200. |===
  201. == Multimedia
  202. image::screenshot.png[block image,800,450]
  203. Press image:reload.svg[reload,16,opts=interactive] to reload the page.
  204. video::movie.mp4[width=640,start=60,end=140,options=autoplay]
  205. video::aHjpOzsQ9YI[youtube]
  206. video::300817511[vimeo]
  207. == Breaks
  208. // thematic break (aka horizontal rule)
  209. ---
  210. // page break
  211. <<<