Potential Extensions (Parser Plugins) - gmarpons/asciidoc-hs GitHub Wiki
Syntactic extensions (aka plugins) can be:
-
Enabled/disabled on user demand.
-
Easily defined using a small and clear API.
This page documents AsciiDoc syntactic features (existent or imagined) that are good candidates at being implemented as syntactic extensions.
Being able to enable/disable differentiating features can be useful in the transition from one tool to another.
Differences are documented here:
-
Different formatting marks, for example for italic text:
'italic text'
or_italic text_
in AsciiDoc Python, only_italic text_
in Asciidoctor (without thecompat-mode
attribute).Example 1. Use of single quoted text with and withoutcompat-mode
in Asciidoctor.With
compat-mode
enabled: single-quoted text.Without
compat-mode
:'single-quoted text'
(quotes are copied verbatim).See https://asciidoctor.org/docs/user-manual/#changed-syntax for a complete list.
-
Asciidoctor allows the document id to be set using above the document header (adds id attribute to
<body>
tag). -
In Asciidoctor, section title underlines must be within 1 character of the length of the title (AsciiDoc allows an offset of 3).
-
Asciidoctor supports up to 6 section levels (to cover all heading levels in HTML) whereas AsciiDoc stops at 5; note the 6 section level is only available using the single-line section title syntax.
-
Asciidoctor enforces symmetric block delimiters (the length of start and end delimiters for a block must match!).
-
Asciidoctor is nice about using a section title syntax inside a delimited block by simply ignoring it (AsciiDoc issues warnings).
-
Asciidoctor skips over line comments in tables, whereas AsciiDoc doesn’t.
-
Asciidoctor only recognizes the single character notation for column and cell formatting (e.g.,
a
but notasciidoc
). -
Asciidoctor supports markdown-style blockquotes as well as a shorthand for a blockquote paragraph.
-
Asciidoctor supports markdown-style headings (section titles).
-
Asciidoctor adds the type attribute on ordered lists to provide hint for numbering style when stylesheet is absent (such as in embedded mode).
-
Asciidoctor recognizes
opts
as an alias for theoptions
attribute. -
Asciidoctor introduces the
hardbreaks
attribute, which inserts a line break character after each line of wrapped text. -
Asciidoctor parses attributes in link macros if an equal sign is found after a comma.
-
Asciidoctor >= 1.5.7 allows attribute names to contain any word character as defined by Unicode. AsciiDoc Python requires attribute names to be Basic Latin.
-
Asciidoctor introduces the
idseparator
attribute to customize the separator used in generated section ids (AsciiDoc hardcodes_
). -
Asciidoctor does not require commas between attributes with quoted values in a block attribute list.
Example 2. No commas between attributes syntax.["horizontal" role="green"] property 1:: does stuff property 2:: does different stuff
If this possible extension was disabled, possible results would be:
-
Ignore the complete attribute list and emit a warning.
-
Accept and process as an attribute the text until the first space, ignore the rest and emit a warning.
-
-
The Admonition block caption can be overridden in Asciidoctor using the caption block attribute.
-
In Asciidoctor, a horizontal ruler can have attributes.
-
Asciidoctor can set the extension for icons using the icontype attribute (AsciiDoc defaults to .png).
-
Asciidoctor has shorthand syntax for attaching id, role, style and options to blocks: https://asciidoctor.org/docs/user-manual/#new-syntax.
-
Find other attributes deleted and deprecated in Asciidoctor here: https://asciidoctor.org/docs/user-manual/#migrate-deprecated.
When the stem
attribute is set in the document header, Asciidoctor recognizes:
stem:[sqrt(4) = 2]
Water (stem:[H_2O]) is a critical component.
AsciiDoc Python has different syntax for mathematical formulas an LaTeX integration: https://asciidoctor.org/docs/user-manual/#mathematical-expressions.
When the experimental
attribute is set in the document header, Asciidoctor recognizes:
-
A macro for creating keyboard shortcuts using the syntax kbd:[key(+key)*.]
Example 4. Keyboard macro syntax.Use kbd:[F11] to Toggle fullscreen.
Result: F11
If this extension was disabled, the result for the above example would be the verbatim string
kbd:[F11]
, and possibly a warning suggesting activating the extension. -
A similar
menu
macro for menu selections.Example 5. Menu macro syntax.To save the file, select menu:File[Save].
-
A similar
btn
macro for UI buttons.Example 6. UI button macro syntax.Press the btn:[OK] button when you are finished.
= Document Title
:icons: font
icon:tags[role="blue"] ruby, asciidoctor
See Callout Annotations.
When the stem
attribute is set in the document header, Asciidoctor recognizes:
[stem]
++++
sqrt(4) = 2
++++
[source,ruby]
----
require 'sinatra' <1>
get '/hi' do <2> <3>
"Hello World!"
end
----
<1> Library import
<2> URL mapping
<3> Response block
[diagram-type, generated-file-name, generated-image-format] // (1) (2) (3) .... // (4) Diagram in appropriate syntax ....
-
The first positional attribute in the attribute list specifies the diagram that is being used.
-
The second, optional positional attribute assigns a file name (i.e.
target
) to the generated diagram. If a target is not specified an auto-generated name will be used. -
The third, optional positional attribute specifies the image format to create, specified as a three character file extension.
-
Place the attribute list directly on top of the delimited literal block (....). You can also use an open block as an alternative (
--
).
[plantuml, diagram-classes, png] // (1) (2) (3)
....
class BlockProcessor
class DiagramBlock
class DitaaBlock
class PlantUmlBlock
BlockProcessor <|-- DiagramBlock
DiagramBlock <|-- DitaaBlock
DiagramBlock <|-- PlantUmlBlock
....
-
The diagram is written in PlantUML so the first positional attribute is assigned the
plantuml
diagram type. -
The name of the generated diagram file (target) is written in the second positional attribute.
-
The output format is entered in the third positional attribute.
Some Asciidoctor features are valid syntax but not recommended practice, nonetheless. It would be useful to offer the following possibilities to the user:
-
Disable this syntax.
-
Allow the syntax but emit a warning when detected.
Some examples taken from https://asciidoctor.org/docs/asciidoc-recommended-practices/:
-
Setext and symmetrix atx-style section titles: https://asciidoctor.org/docs/asciidoc-recommended-practices/#section-titles
Example 11. Non-recommended section title syntax.This is a setext-style level 2 section title -------------------------------------------- == This is a symmetric atx-style level 2 section title ==
-
Long delimiter lines for delimited blocks: https://asciidoctor.org/docs/asciidoc-recommended-practices/#delimited-blocks.
-
Non-intuitive use of list markers in nesting: https://asciidoctor.org/docs/asciidoc-recommended-practices/#lists.
Example 12. Non-recommended list marker use.Non-intuitive nested list: *** first * nested item *** second *** third Another non-intuitive nested list: - first * nested item - second - third
Fluent is a localization system for natural-sounding translations, supported by Mozilla.
It would be nice to be able to write parameterized text that, relying on certain AsciiDoc attributes (maybe marked syntactically), and using Fluent selectors, embeds the localization logic in pure AsciiDoc.
{$userName} {$photoCount ->
[one] added a new photo
*[other] added {$photoCount} new photos
} to {$userGender ->
[male] his stream
[female] her stream
*[other] their stream
}.
Fluent has functions for formatting dates and numbers and would be also useful to call them within AsciiDoc.
-
Org Mode timestamps and time ranges.
-
Org mode syntax for section titles, including:
-
TODO items, with priorities and check-boxes.
-
Tags.
-
-
Org Mode radio tagets. See https://orgmode.org/org.html#Radio-Targets. Convert any text in an automatic internal reference. Syntax:
<<<My target>>>
. -
Org mode section properties as Asciidoc Attributes. The idea is that attribute definitions in consecutive lines from de section title would be considered properties attached to the section, maybe using a special syntax marker for the attribute name or the attribute value.
-
Spreadsheed formulas in tables.
-
Syntax for automatically inserting a list of figures, a list of tables, etc. See, for example, https://github.com/asciidoctor/asciidoctor-extensions-lab/issues/111.
-
Flexible and automatic numbering of equations, examples, etc.
DocBook has a long list of labels to attach meaning to document elements: https://github.com/asciidoctor/asciidoctor-extensions-lab/issues/111.
-
Idea taken from a comment in the proposal for the AsciiDoc Language WG:
Instead of relying on styling for things like:
Pass an [.type]#std::string# object to the [.func]#setName# function.
Have a specific special syntax, like:
Pass an [:type]#std::string# object to the [:function]#setName# function.
-
Idea taken from a chanel in the Write the Docs Slack space:
Is there a way to stop Asciidoc from substituting “...” for the single ellipsis character (…)?We never want it to make this substitution.
There is a way: backslash escaping. But we could make a customization option to decide what substitutions are applied.