Expand description
AsciiDoc parser.
Parse strings, files, readers, or inline fragments into an abstract syntax tree with source locations and recoverable warnings.
§Quick start
Use parse, parse_file, parse_from_reader, or parse_inline.
Parser provides a builder-style alternative. ParseResult owns the AST
and its backing text; keep the result alive while borrowing ParseResult::document.
use acdc_parser::{Options, parse};
let content = r#"= Document Title
This is a paragraph.
== Section Title
This is a subsection."#;
let parsed = parse(content, &Options::default())?;
let document = parsed.document();
assert!(!document.blocks.is_empty());
for warning in parsed.warnings() {
eprintln!("{warning}");
}§Cargo features
pre-spec-subs(default): experimental blocksubs=settings and their AST types. Without it, explicit settings report source recovery and use block defaults.setext(off by default): legacy underlined headings, enabled throughOptionsBuilder::with_setext()when the feature is compiled.network(off by default): HTTP(S) includes, subject to safe mode and caller permission.
The parser uses the draft AsciiDoc specification and Asciidoctor as references;
it does not claim complete conformance. A successful parse may contain recovered
content. Check ParseResult::source_recovery when an application requires
complete input, and ParseResult::warnings for all collected diagnostics.
§Checklist markers
acdc treats [X] as a checked list marker, alongside [x] and [*].
Asciidoctor leaves [X] in the item text. This is an intentional acdc
extension.
§Include loading
Parsing defaults to SafeMode::Secure. Include directives become links
without reading their targets. Select a lower mode to enable include reads.
Options::include_loader defaults to IncludeLoader::System, the
filesystem and optional HTTP(S) loader. Use IncludeLoader::custom to
supply sources from an editor or another store. In modes below Secure,
IncludeLoader::Disabled preserves literal directives without reading targets.
These settings apply to string, reader, and file input; a custom provider does
not lower the safe mode or grant URI permission.
§Local include confinement
SafeMode::Safe and SafeMode::Server use the effective include base as
their local boundary. Set it through OptionsBuilder::with_base_dir; file
input otherwise uses the entry file’s directory, and string or reader input
uses the current directory. Given an entry document at
/workspace/docs/main.adoc:
../shared.adocbecomes/workspace/docs/shared.adocand emits a warning;/tmp/shared.adocbecomes/workspace/docs/tmp/shared.adocand emits a warning;- a nested include from
/workspace/docs/chapters/part.adocstill uses/workspace/docsas its boundary.
The check does not resolve symlinks. If /workspace/docs/linked.adoc points to
/private/secret.adoc, including linked.adoc reads /private/secret.adoc.
These path transformations match asciidoctor; they are not strict symlink
containment.
§Remote includes
HTTP(S) includes need a safe mode below SafeMode::Secure and the caller’s
allow-uri-read attribute. A document cannot grant itself this permission.
IncludeLoader::System also needs the network feature.
A custom IncludeSourceProvider can supply permitted URI content through
another transport.
On bare WebAssembly targets such as wasm32-unknown-unknown, network does
not provide an HTTP client. If the system loader attempts an HTTP(S) include,
the parser reports a warning and leaves the directive unresolved.
Fetch content in the host before parsing and supply it through a custom provider.
§Include source size limit
Each include can select up to 10 MiB of normalized UTF-8 text, including newlines.
The parser checks this limit before and after indent=.
Use lines=, tag=, or tags= to select a small part of a larger source.
If the selected text exceeds the limit, parsing fails with Error::IncludeSourceTooLarge.
Excess tag metadata causes Error::IncludeSelectionTooComplex.
All includes in one parse share a budget, with a default of 64 MiB.
Each include counts its selected UTF-8 text after indent=, plus one byte
for a separating newline if the text is not empty. This count precedes
nested processing and removal of comments and inactive conditionals.
Repeated includes count each time.
Nested includes share the budget; their expanded output is not counted again
in the parent. Exceeding the budget causes Error::IncludeExpansionTooLarge
at the include directive. Set OptionsBuilder::with_max_total_include_bytes
to change the budget in bytes. Zero permits only empty selections.
Document attributes cannot change it.
Safe-mode permissions and the per-include limit still apply.
A finite lines= selection stops at its highest requested line.
Errors after that line do not affect the result.
The parser removes trailing whitespace from each line independently.
Full includes, open-ended ranges, and tag selections read to the end of the source.
The built-in HTTP(S) loader has a separate 10 MiB limit for bytes read after decompression. This includes bytes read ahead of the selection. When a finite line selection is complete, the loader closes the response without reading the rest.
These resource limits differ from asciidoctor.
They do not limit scan time.
They do not apply to the entry document.
§Include indentation
The indent attribute on an include accepts 0..=4096. Larger values return
a located Error::IncludeIndentTooLarge before the target is read. This fixed
safety limit is an intentional acdc security policy, not an AsciiDoc language
requirement. It prevents one directive from requesting an unbounded indentation
prefix and deliberately diverges from asciidoctor, which has no documented or
implemented maximum.
§Table limits
Tables accept at most 100 logical columns and 1,000 rows, bounding an accepted
table to 100,000 materialized cells. The column bound also applies to cols
multipliers, cell duplication counts, and column spans; row spans are bounded by
the row limit. Larger requests return a located Error::Parse.
These fixed internal safety limits cannot be changed through Options or
document attributes. They intentionally diverge from asciidoctor, which has no
equivalent table dimension cap.
Structs§
- Admonition
- An
Admonitionrepresents an admonition in a document. - Anchor
- An
Anchorrepresents an anchor in a document. - Attribution
- An attribution in a blockquote (the author/source of the quote).
- Audio
- An
Audiorepresents an audio block in a document. - Author
- An
Authorrepresents the author of a document. - Autolink
- An
Autolinkrepresents an inline autolink in a document. - Block
Metadata - A
BlockMetadatarepresents the metadata of a block in a document. - Bold
- A
Boldrepresents a bold section of text in a document. - Button
- A
Buttonrepresents an inline button in a document. - Callout
List - A
CalloutListrepresents a callout list in a document. - Callout
List Item - A
CalloutListItemrepresents an item in a callout list. - Callout
Ref - A
CalloutRefrepresents a callout reference marker within verbatim content. - Cite
Title - A citation title in a blockquote (the title of the cited work).
- Column
Format - Column format specification for table formatting
- Comment
- A comment in a document that produces no output.
- Cross
Reference - A
CrossReferencerepresents an inline cross-reference (xref) in a document. - Curved
Apostrophe - A
CurvedApostropherepresents a curved apostrophe section of text in a document. - Curved
Quotation - A
CurvedQuotationrepresents a curved quotation section of text in a document. - Delimited
Block - A
DelimitedBlockrepresents a delimited block in a document. - Description
List - A
DescriptionListrepresents a description list in a document. - Description
List Item - An item in a description list (term + description).
- Discrete
Header - A
DiscreteHeaderrepresents a discrete header in a document. - Document
- A
Documentrepresents the root of anAsciiDocdocument. - Document
Attribute - An accepted document-attribute assignment in the document body.
- Document
Attribute Value - A defined document attribute, including its retained text representation.
- Document
Attributes - Validated document attributes with universal defaults.
- Element
Attributes - Element-level attributes (for blocks, sections, etc.).
- Footnote
- A
Footnoterepresents an inline footnote in a document. - Header
- A
Headerrepresents the header of a document. - Highlight
- A
Highlightrepresents a highlighted section of text in a document. - Icon
- An
Iconrepresents an inline icon in a document. - Image
- An
Imagerepresents an image block in a document. - Include
Source - An opened include source.
- Include
Source Error - Failure returned by an
IncludeSourceProvider. - Index
Term - An
IndexTermrepresents an index term in a document. - Italic
- An
Italicrepresents an italic section of text in a document. - Keyboard
- A
Keyboardrepresents an inline keyboard shortcut in a document. - Line
Break - A
LineBreakrepresents a line break (inline). - Link
- A
Linkrepresents an inline link in a document. - List
Item - A
ListItemrepresents a list item in a document. - Location
- A
Locationrepresents a location in a document. - Mailto
- An
Mailtorepresents an inlinemailto:in a document. - Menu
- A
Menurepresents an inline menu in a document. - Monospace
- A
Monospacerepresents a monospace section of text in a document. - Options
- Options
Builder - Builder for
Optionsthat provides an API for configuration. - Ordered
List - An
OrderedListrepresents an ordered list in a document. - Owned
Source - Source text with no AST — returned by consumers (e.g. the LSP) when the input is available but parsing failed.
- Page
Break - A
PageBreakrepresents a page break in a document. - Paragraph
- A
Paragraphrepresents a paragraph in a document. - Parse
Inline Result - Successful inline-only parse output: the inline-node slice plus the
buffers it borrows from, plus any non-fatal warnings. Counterpart to
ParseResultfor the inline-only entry point. - Parse
Result - Owns a parsed document, its backing text, and non-fatal warnings.
- Parser
- Type-based parser for
AsciiDoccontent. - Pass
- A
Passrepresents a passthrough macro in a document. - Plain
- Ordinary inline text that inherits processing from its enclosing block.
- Position
- A
Positionrepresents a human-readable position in a document — one ASGlocationBoundary. For byte offsets, useLocation.absolute_start/Location.absolute_end. - Raw
- Inline passthrough text with its own substitution policy.
- Reference
- Reference metadata for a cross-reference target.
- Section
- A
Sectionrepresents a section in a document. - Source
Location - Source location information combining a file path with a
Locationspan. - Source
Url - A parsed URL that preserves the author’s original input for display.
- Standalone
Curved Apostrophe - A
StandaloneCurvedApostropherepresents a standalone curved apostrophe character. - Stem
- A
Stemrepresents an inline mathematical expression. - Stem
Content - Content of a stem block with math notation.
- Subscript
- A
Subscriptrepresents a subscript section of text in a document. - Superscript
- A
Superscriptrepresents a superscript section of text in a document. - Table
- A
Tablerepresents a table in a document. - Table
Column - A
TableColumnrepresents a column/cell in a table row. - Table
OfContents - A
TableOfContentsrepresents a table of contents block. - Table
Presentation - Table decoration resolved from the attributes at the table’s source position.
- Table
Row - A row in a table, containing one or more columns (cells).
- Thematic
Break - A
ThematicBreakrepresents a thematic break in a document. - Title
- A title in a document (section titles, block titles, document title, etc.).
- TocEntry
- A
TocEntryrepresents a table of contents entry. - Unordered
List - A
UnorderedListrepresents an unordered list in a document. - Url
- An
Urlrepresents an inline URL in a document. - Verbatim
- Text from a literal, listing, or source context.
- Video
- A
Videorepresents a video block in a document. - Warning
- A non-fatal condition detected during parsing.
Enums§
- Admonition
Variant - The variant/type of an admonition block.
- Attribute
Value - An
AttributeValuerepresents the value of an attribute in a document. - Block
- A
Blockrepresents a block in a document. - Callout
RefKind - The kind of callout reference marker (how it was expressed in the source).
- Caption
- The caption a titled block takes.
- Caption
Kind - A block category with its own caption attribute and counter.
- Column
Style - Column content style
- Column
Width - Column width specification
- Comment
Kind - The syntactic form a
Commentoriginated from. - Delimited
Block Type - The inner content type of a delimited block.
- Document
Attribute Assignment - An accepted set or unset document-attribute assignment.
- Error
- Form
- The form of an inline formatting element (how it was expressed in the source)
- Horizontal
Alignment - Horizontal alignment for table cells
- Include
Loader - Selects how the parser loads include sources.
- Include
Source Error Kind - Classification of a source-provider failure.
- Include
Source Target - A fully resolved include target presented to an
IncludeSourceProvider. - Index
Term Kind - The kind of index term, encoding both visibility and structure.
- Index
Term Relationship - A relationship from an index entry to another index term.
- Inline
Macro - An inline macro - a functional element that produces inline content.
- Inline
Node - An
InlineNoderepresents an inline node in a document. - List
Item Checked Status - A
ListItemCheckedStatusrepresents the checked status of a list item. - Passthrough
Kind - Safe
Mode - Controls include access and exposure of local paths during parsing.
- Section
Kind - The structural category of a section.
- Source
- The source location for media content (images, audio, video).
- Stem
Notation - Notation type for mathematical expressions.
- Substitution
- An
AsciiDocsubstitution or named substitution group. - Substitution
Op - A substitution operation to apply to a default substitution list.
- Substitution
Spec - Specification for substitutions to apply to a block.
- Table
Frame - The outer border applied to a table.
- Table
Grid - The rules drawn between table cells.
- Table
Stripes - The body rows that receive a background fill.
- Vertical
Alignment - Vertical alignment for table cells
- Warning
Kind - Categorised non-fatal conditions.
- Xref
Caption Label - Selects the label used by an automatic cross-reference to a numbered caption.
- Xref
Signifier - The word that introduces a section number in an automatic cross-reference.
- Xref
Style - The display style for an automatic cross-reference.
Constants§
- HEADER
- Default substitutions for header content.
- ICON_
SIZES - MAX_
SECTION_ LEVELS - MAX_
TOC_ LEVELS - NORMAL
- Default substitutions for normal content (paragraphs, etc).
- UNNUMBERED_
SECTION_ STYLES - Section styles that should not receive automatic numbering.
- VERBATIM
- Default substitutions for verbatim blocks (listing, literal).
Traits§
- Include
Source Provider - Supplies bytes for include targets resolved by the parser.
Functions§
- parse
- Parse
AsciiDoccontent from a string. - parse_
file - Parse
AsciiDoccontent from a file. - parse_
from_ reader - Parse
AsciiDoccontent from a reader. - parse_
inline - Parse inline
AsciiDoccontent from a string. - parse_
text_ for_ quotes - Parse text for inline formatting markup (bold, italic, monospace, etc.).
- strip_
quotes - Strip surrounding single or double quotes from a string.
- substitute
- Apply a sequence of substitutions to text.
- substitute_
attributes - Expand known attribute references once, leaving unresolved references unchanged.
Type Aliases§
- Attribute
Name - An
AttributeNamerepresents the name of an attribute in a document. - Role
- Subtitle