Expand description
adoctra: umbrella crate. Re-exports the core editor/parse API and, behind
feature flags, the native backends.
let result = adoctra::parse("= Hello\n\nWorld");
assert!(result.diagnostics.is_empty());
use adoctra::Backend;
let html = adoctra::html::HtmlBackend::new().convert(&result.document).unwrap();
assert!(String::from_utf8(html).unwrap().contains("<h1>Hello</h1>"));Re-exports§
pub use adoctra_html as html;
Modules§
- extension
- The extension API (block, block macro and tree processors). Extension API: adoctra’s own processors at the points where Asciidoctor invokes its extensions (user decision 2026-11-05: an own Rust API, not Ruby API compatibility).
Structs§
- Attributes
- Ordered map of document attributes.
BTreeMapkeeps output deterministic, which matters for snapshot/TCK testing. - Author
- Author
Details - An author as the HTML header shows it (
Document::authors): the effective name after replacements and the email after macros. - Binary
Resource - Original resource bytes (an encoded include or an embedded image).
content_typeis a type the source reports (e.g. an HTTPContent-Type), if any. - Block
- A block node: its source span, an optional id, and its kind.
- Block
Macro Request - A block macro handed to a
BlockMacroProcessor. - Block
Request - A block handed to a
BlockProcessor. - Date
Time - A wall-clock time with its UTC offset, as the host’s clock reports it.
- Diagnostic
- Diagnostic
Cursor - A logger cursor need not identify the physical span (selected includes and reader lookahead can change its file and line in the reference processor).
- Diagnostic
Report - Presentation overrides for conversion logs; never used to rewrite spans or remove editor diagnostics. Unspecified severity/text use the diagnostic’s.
- Document
- A whole parsed document: header attributes plus a sequence of blocks.
- Document
Dates - The times behind Ruby’s
fill_datetime_attributes:localis now (localdate,localtime, …),documentthe input’s modification time (docdate,doctime, …). A host honouringSOURCE_DATE_EPOCHpasses that instant in UTC for both, and the current time asdocumentwhen the input has no file. - Document
Header - Source declarations in a document header. Effective (possibly overridden)
metadata lives in
Document.attributes. The title remains the first level-0 heading inblocks, avoiding a second mutable copy of its inline tree. - Extension
Attributes - Block attributes in Ruby’s insertion order (a Ruby
Hash): metadata lines in reading order, then the keys the extension point adds (positional names, default attributes,cloaked-context). Setting an existing key keeps its position. A key can hold Ruby’snil: an empty positional value ([,svg]) is a key without a value, and Ruby code that walks the hash (asciidoctor-diagram’s checksum) sees it. - Include
Limits - Bounds for recursive resource expansion (the primary source is excluded).
- Include
Resource - An include’s immutable decoded source. A finite line selection may recover an intact prefix when the unread tail cannot be decoded. The prefix starts at byte zero, so physical line numbers and decoded UTF-8 offsets stay valid.
- Memory
Resources - Application-owned resources in a virtual directory tree. Names use
/on every platform; an initial slash addresses the virtual root..and..are normalized, but traversal above that root is rejected. No URL decoding, filesystem access or network access is performed. - NewBlock
- A block created by a processor, with its attributes.
title,caption,id,role,style,reftextand*-optionkeys become the block’s metadata; other named keys stay block attributes; positional keys are dropped. - Omitted
Source Line - A whole undecodable line excluded from an include snapshot.
offsetis the insertion point in its retained UTF-8 text;lineis the original one-based physical line. Bytes include the original line ending, if any. - Omitted
Source Span - A byte range within an omitted physical line, including neither an invented UTF-8 decoding nor a Unicode column. The source ID is the diagnostic’s.
- Output
Paths - The output file and directory of a document converted for a file
(Ruby’s
outfile/outdir). - Parse
Options - Parse
Result - The result of parsing for editor use: always succeeds, carries diagnostics.
- Process
Context - What a processor can see of the document and how it reports problems.
- Registry
- The processors a host registers for parsing.
- Resource
- Resource
Error - Resource
Request - A request after target attribute substitution.
referreris a canonical name returned by this same provider, or None for a top-level resource. - Revision
- Source
File - Source
Id - Source
Map - Source
Position - One-based line and Unicode scalar column (not a UTF-16 editor column).
- Span
- A byte range
[start, end)in the original source. - System
Path - A resolved path and the warnings Ruby logs while resolving it.
- Token
Enums§
- AttrKey
- A key of
ExtensionAttributes: Ruby’s integer keys for positional values and string keys for named ones. - Block
Context - The context of the block a
BlockProcessorreplaces: the delimited block’s own context or a paragraph (Ruby’scloaked-context). - Block
Kind - Block-level element kinds.
- Content
Model - How a
BlockProcessorreceives the block’s lines (Ruby’scontent_model). The lines are always the preprocessed lines of the block (includes and conditionals applied). - Diagnostic
Location - Docinfo
Location - Where the converter places docinfo content.
- Error
- Include
Input - Provider input awaiting the reader’s line/tag selection. Only UTF-8 and ASCII-8BIT defer validation; transcoding codecs validate consumed bytes.
- Inline
- Inline (phrase-level) elements. Every variant carries its source
Span. - Macro
Content - How a
BlockMacroProcessorreceives the text in its brackets. - NewBlock
Kind - The kind of block a processor creates. Text sources are split into
lines with trailing whitespace removed, like Ruby’s
Block.newwith a string:source. - Output
Target - The output location a host resolved before parsing (absolute paths, as
Ruby’s
normalize_system_pathgives them). - Resource
Error Kind - Safe
Mode - Ruby’s
SafeModelevels. - Severity
- Token
Kind
Constants§
- COMPATIBILITY_
VERSION - Parse AsciiDoc source into a
ParseResult(never fails on syntax). The Asciidoctor release whose behavior adoctra reproduces (compatibility/asciidoctor-version), exposed to documents as the lockedasciidoctor-versionattribute like Ruby’sDocument#initialize.
Traits§
- Backend
- Block
Macro Processor - Handles
name::target[attrlist]lines. - Block
Processor - Handles a block whose style is its name.
- Conversion
Start - A converter’s work at the start of conversion. Ruby’s
convert_documentbuilds the head (reading a custom stylesheet, which can also activate the URI cache) after converting the document title and before the header outline and the body convert, so its reads and warnings precede those of the body’s images. Core converts the body while parsing, so a converter that reads resources in its head passes this hook toparse_resource_with_startorparse_with_start; core calls it once at that point and reports the returned warnings as conversion diagnostics there. - Resource
Provider - Tree
Processor - Runs on the finished document (after reading and conversion-time substitutions), before a backend converts it.
Functions§
- is_
root_ path - Ruby’s
PathResolver#root?for this host:/x, and on Windows alsoC:/x,C:\xand\x. - parent_
system_ dir - Ruby’s
File.dirnameof a posixified absolute or relative path: the root (/, orC:/on Windows) stays a root, a bare name gives.. - parse
- parse_
resource - Parse a registered snapshot, expanding includes through the supplied provider.
Only an invalid primary id returns Err; include failures are diagnostics.
If the provider supplies a
ResourceProvider::document_path, it determines lockeddocfile,docdir,docnameanddocfilesuffixattributes for the primary document, overriding those keys inoptions.attributes. - parse_
resource_ with_ start parse_resourcewith a converter’sConversionStarthook, called where Ruby’s converter starts the document (see the trait).- parse_
with_ options - Parse one source with its identity and hard attribute overrides. The caller
retains the corresponding
SourceMap; parsing performs no file I/O. - parse_
with_ start parse_with_optionswith a converter’sConversionStarthook.- posixify_
path - Ruby’s
PathResolver#posixifyfor this host: on Windows backslashes become slashes; elsewhere the path is unchanged. - resolve_
system_ path - Ruby’s
PathResolver#system_path(target, start, jail, target_name:, recover:)for a host (e.g. a CLI resolving its output paths):startis absolute,jail(if any) absolute. Withrecoveran escape from the jail is moved inside it with Ruby’s warnings; without it the result is Ruby’sSecurityErrormessage, e.g.to_dir /x is outside of jail: /doc (disallowed in safe mode). - tokens
- Tokenize AsciiDoc source for syntax highlighting.
- tokens_
resource - Highlight a registered document and its includes. Each token belongs to one original source; tokens crossing source boundaries are split into fragments.
- tokens_
with_ options - Highlight one source using the same source identity and attribute options.