AsciiDocExtensions
Extension methods for AsciiDoc content parsing that complement the AsciiDocSharp library. Provides document attribute extraction and hierarchical section navigation.
public static class AsciiDocExtensions
1. Methods
1.1. FindSection(string, string)
Finds a section by hierarchical path and returns its body content (excluding the heading itself). Path segments are separated by / and matched case-insensitively.
public static string FindSection(string content, string path)
| Name | Type | Description |
|---|---|---|
content |
string |
Raw AsciiDoc content string. |
path |
string |
Hierarchical section path, e.g. |
Returns: string — The section body text (trimmed), or null if the section path is not found. Body includes subsection headings but excludes the matched section’s own heading line.
1.2. GetAttribute(string, string)
Extracts a single document attribute value by key (case-insensitive).
public static string GetAttribute(string content, string key)
| Name | Type | Description |
|---|---|---|
content |
string |
Raw AsciiDoc content string. |
key |
string |
The attribute name to look for. |
Returns: string — The attribute value, or null if the attribute is not found.
1.3. GetAttributes(string)
Extracts all AsciiDoc document attributes (:key: value) from the content. When duplicate keys exist, the last occurrence wins.
public static Dictionary<string, string> GetAttributes(string content)
| Name | Type | Description |
|---|---|---|
content |
string |
Raw AsciiDoc content string. |
Returns: Dictionary<string, string> — A dictionary of attribute key-value pairs. Keys preserve original casing.
1.4. GetSectionNames(string)
Returns all top-level section names (level 2, i.e. ==) from the content.
public static string[] GetSectionNames(string content)
| Name | Type | Description |
|---|---|---|
content |
string |
Raw AsciiDoc content string. |
Returns: string[] — An array of section heading texts in document order.