Yet another ASCIIDoc, Markdown and RestructuredText cheatsheet
This article is a cheatsheet/ summary on the (my) most used markup languages. It is not a tutorial, but a quick reference for those who already know the basics of each markup language. |
This article is a work-in-progress and has a long table with many columns. If you are reading this on a mobile device, you may want to switch to landscape mode or use a bigger screen. |
Context
I write using
AsciiDoc
AsciiDoc is a human-readable document format, semantically equivalent to DocBook XML, but using plain-text mark-up conventions. AsciiDoc documents can be created using any text editor and read “as-is”, or rendered to HTML or any other format supported by a DocBook tool-chain, i.e. PDF, TeX, Unix manpages, e-books, slide presentations, etc. Common file extensions for AsciiDoc files are adoc and historically txt (as encouraged by AsciiDoc's creator).
,
Markdown
Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber created Markdown in 2004 as an easy-to-read markup language. Markdown is widely used for blogging and instant messaging, and also used elsewhere in online forums, collaborative software, documentation pages, and readme files.
and
ReStructuredText
reStructuredText (RST, ReST, or reST) is a file format for textual data used primarily in the Python programming language community for technical documentation.
depending on the kind of text. Each
Markup_language
A markup language is a text-encoding system which specifies the structure and formatting of a document and potentially the relationships among its parts. Markup can control the display of a document or enrich its content to facilitate automated processing.
has its pros and contras, and I think that using the right tool for each job makes a lot of sense.
This article is a cheatsheet of the most common elements I use in each markup language. I will be updating it as I find/ remember elements that I need to use. == TLDR
Markdown is my go-to for simple articles, RestructuredText for complex web content, and ASCIIDoc for long-form, feature-rich projects. Understanding the strengths and limitations of each helps me optimize my content creation process.
Because of that my use of markup languages is usually as follows:
Markdown: For Simplicity and Readability
-
When I Use It: Ideal for articles that don’t require complex formatting. I often use it for posts without a Table of Contents or advanced code snippets. That is the case in most of the articles I write and all my personal notes.
-
Why: Markdown’s simplicity and readability make it perfect for quick, clean content. It helps me keep the structure lean and stay focused on the content.
-
Limitations: I avoid using Markdown for content needing advanced elements like admonitions or tables, as these are challenging to implement effectively in Markdown. For some of this features, I wrote some shortcodes for Nikola (the static site generator I use).
RestructuredText: For Web Content Richness
-
When I Use It: Chosen for articles on my website that demand more sophisticated elements. I use it mainly for articles with admonitions.
-
Why: Its support for directives like tables, admonitions, notes, and warnings makes RestructuredText versatile for web-centric content.
-
Flexibility: It strikes a balance between simplicity and advanced formatting, filling the gap where Markdown falls short. (Although I have to admit that I am not a big fan of the syntax, such as the headings)
ASCIIDoc: For long-form articles and books
-
When I Use It: My preference for long-form articles, books, and other comprehensive documentation. I am using it for my book on digital marketing
-
Why: ASCIIDoc’s rich feature set allows for intricate structure and extensive customization. Its ability to include external files, define variables, and apply themes makes it unbeatable for complex projects.
-
Output Variety: The flexibility to compile content into formats like EPUB, PDF, and HTML is particularly valuable for diverse publishing needs.
Comparison Table
Element | Markdown | Rest | ASCIIDoc |
---|---|---|---|
Headers |
|
|
|
Links |
|
|
|
Bold text |
|
|
|
Italic text |
|
|
|
underlined text |
|
|
underlined text |
Strikethrough text |
|
|
|
Custom style (role in Asciidoc) |
|
||
Quotation (simple) |
|
|
|
Quotation (with author and title) |
|
|
|
Code snippets |
|
This is a directive with many options. Check https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#directive-code-block for more information. |
if you want to put a code snippet in a bullet point list or similar, you have to add it in a new line after a +. This way it will have the same indentation and will be part of the same div
|
Image (simple) |
|
|
|
Variables |
|
|
|
Table (simple) |
markdown-simple-table-example.md (Source) ....
| Header 1 | Header 2 | Header 3 |
|----------|----------|----------|
| Row 1 | Data 1 | Data 2 |
| Row 2 | Data 3 | Data 4 |
....
|
rst-simple-table-example.rst (Source) .. table::
:class: my-table
+------------+------------+------------+
| Header 1 | Header 2 | Header 3 |
+============+============+============+
| Row 1 | Data 1 | Data 2 |
+------------+------------+------------+
| Row 2 | Data 3 | Data 4 |
+------------+------------+------------+
|
asciidoc-simple-table-example.adoc (Source) [options="header"]
|===
| Header 1 | Header 2 | Header 3
| Row 1 | Data 1 | Data 2
| Row 2 | Data 3 | Data 4
|===
|
References in-document (simple) |
|
|
set the anchor
call the anchor. Thsi will use the title of the section it refers to.
|
Table (with code snippet) |
|
|
asciidoc-table-with-code-snippet.adoc (Source) |===
a| Source code example:
[source,python]
----
print("Hello, World!")
----
|===
|
Line/ Separator |
|
|
|
By the way, this article and cheatsheets were made using asciidoc and the Nikola Listings feature. |