Introduction

Target audience: Developers, technical writers, and anyone wishing to write technical documentation or rich articles.

AsciiDoc is a lightweight markup language designed for writing structured technical documents, articles, books, or even presentations. It stands out for its readability, syntactic richness, and its ability to generate various formats (HTML, PDF, DocBook, etc.). In this article, we will explore the essential syntax of AsciiDoc and provide tips for a quick start.

What is AsciiDoc?

AsciiDoc is a document description language, similar to Markdown but more powerful. It allows for the effective structuring of text, headings, lists, tables, code blocks, and much more. Its versatility makes it a popular choice for open source project documentation, book writing, and web publishing.

Why choose AsciiDoc?

  1. Readable and intuitive syntax.

  2. Native support for complex structures (tables, notes, admonitions, etc.).

  3. Multi-format generation (HTML, PDF, ePub, DocBook…).

  4. Easy integration with static site generators like JBake or Antora.

  5. Advanced customization with attributes and extensions.

Use Case Diagram

A use case diagram presents the main interactions between users and the system. Here is a simple example for a documentation system:

Diagram

Mind Map Diagram

The mind map is ideal for exploring concepts related to AsciiDoc and their relationships:

Diagram

Flow Diagram

A flow diagram describes the process of generating an AsciiDoc document:

Diagram

Basic Structure of an AsciiDoc File

An AsciiDoc file generally begins with a title, optional attributes, and then the structured content. Here is a minimal example:

= Titre Principal
Auteur
2024-09-03
:toc:
:icons: font

Votre contenu commence ici...

Fundamental Syntax

Headings and Sections

AsciiDoc supports several levels of headings:

= Titre de niveau 1
== Titre de niveau 2
=== Titre de niveau 3
==== Titre de niveau 4

Bold, Italic, and Monospace Text

*gras* _italique_ `monospace`

Bulleted and Numbered Lists

* Élément 1
* Élément 2

. Premier
. Deuxième
. Troisième
Lien standard : https://asciidoc.org[AsciiDoc]
Image : image::images/logo.png[AsciiDoc Logo]

Code Blocks

[source,python]

def hello(): print("Hello AsciiDoc!")

Tables

|===
| Colonne 1 | Colonne 2

| Valeur A
| Valeur B

| Valeur C
| Valeur D
|===

Notes and Admonitions

AsciiDoc provides visual information blocks:

NOTE: Ceci est une note importante.
TIP: Conseil utile pour l’utilisateur.
WARNING: Attention à ce point.

Using Attributes and Variables

Custom attributes allow for the reuse of values or the configuration of behaviors:

:project-name: AsciiDoc Explorer

Le projet s’appelle {project-name}.

Common Use Cases

  • Open source project documentation (README, technical guides) - Writing books and ebooks - Automatic generation of static websites (JBake, Antora) - Technical presentations

Best Practices

  • Use consistent headings and an automatic table of contents (:toc:). - Favor admonitions to draw attention to key points. - Structure your files to facilitate maintenance. - Take advantage of annotated code blocks to illustrate examples.

Conclusion

AsciiDoc is a powerful and accessible tool for writing any technical documentation or structured article. Its rich syntax, combined with multi-format generation, makes it a choice ally for demanding developers and writers. Try AsciiDoc in your next project and discover the difference!

For Further Reading

Share your experiences and tips in the comments!

Related articles