On opinionated AsciiDoctor cheat sheet for authoring HTML, by Jakub Holý
Structure
Document header = Main Header (1) Jakub Holý <holyjak@example.com> (2) v1.2.3, 2021-09-29: my optional revision remark (3) :author: Jakub Holý (4) :email: <holyjak@example.com> (5) :revnumber: 1.2.3 (6) :revdate: 2021-09-29 (7) :revremark: my optional revision remark (8) (9)
|
Attributes
Document attributes Configure and turn on/off built-in features, built-in asset locations, set "variables" for reuse elsewhere in the document. See rules for values. Most document attributes are set right under the main header / document title, some can be (re)set anywhere (e.g. = Document Title :sectnums: // turn on a boolean attr :!sectnums: // turn it off :imagesdir: ./my/img/subdir/ // built-in attr. with a value :my-homepage: https://holyjak.cz // a custom attribute A reference to an attribute such as link:{my-homepage}[my www] will be replaced with the value automatically. See Document Attributes Reference for a full list. |
|
Element attributes Override the built-in settings of blocks, macros, or inline elements and add custom settings (e.g. id, CSS classes) by using attribute lists. Attributes are comma-separated and can be positional (come first) and/or named: image:path[Image alt text,200,150] image:path["Image alt text",height=150,width=200]
For blocks and block elements, put the attributes on the preceding line: [square] * one * two |
Section Titles
|
Section Titles Mark titles with = Document title (h1) == Level 1 (h2) ... ====== Level 5 (h6) :sectnums: :sectnumlevels: 2 (1) == Numbered section :!sectnums: == Unnumbered again
|
Paragraphs
Paragraphs
To pass inline text through unchanged to HTML, wrap with three +++<div id=x>+++ |
|||
Assign id and CSS class(es) (a.k.a. roles) to inline text Roles = CSS classes can be assigned similarly as ID,
see Links and anchors below. |
Text Formatting
|
Text Formatting
|
Blocks and admonitions
|
Admonitions
|
||||||||||||||||||
|
Blocks General structure of a block:
.Optional title [optional attributes] <separator (2 or 4 characters)> <content> <separator>
|
||||||||||||||||||
Source code listing [source] ---- clojure, SQL ; <1> C-like // <2> Python etc. # <3> XML <!--4--> # Include from a file, specific lines only (-1 = until the end): include::filename.txt[lines=7;14..25;30..-1] # or include regions between tags; also, un-indent: include::lib/app.rb[tag=mytag,indent=0] ---- <1> callout <2> callout <3> callout <4> callout When including regions by tags, mark them using line comments like these: # tag::mytag[] ... # end::mytag[] |
Lists
Lists (Un)ordered lists source
* Level 1 item of an unordered list ** Level 2, ... up to 5 *** Lists can be indented. Leading whitespace isn't significant. . Nested level 1 ordered list item .. ordered list item 2nd level + ==== To include complex content, unindent it and put the list continuation sign `+` on the line between it and the list item ==== .. but a literal paragraph does not require a list continuation: $ echo "it works" .. end [] . To split a list into 2, put an empty line and a block attribute line (possibly empty) before the second list (Un)ordered lists rendered
|
Links and anchors
Anchors Block or a section heading: use a block anchor Inline, on quoted text using either formatting marks such as Anchors can be used anywhere where macro substitution applies. |
|||||||||||||||||
Links Link to an anchor via
Beware: Some URLs look like formatting and confuse the parser. To fix, wrap like this Supported attributes: id, role (= CSS class), title, window (or append |
Images
|
Images Block image: Inline image: same as block image, but single Positional attributes: Named attributes (1 applies only to block images):
|
Tables
|
Tables Table source
[cols="20,80"] |=== | Country | City | Norway | Oslo | Czechia | Ostrava | footer | after empty line |=== Example 2. Table rendered
|
Extra
|
Extra
|