Supported Link Types
Linkspector extracts and validates all AsciiDoc hyperlink types:Direct URLs
Auto-detected HTTP/HTTPS links
Link Macros
link: macro syntaxAnchors
Four types of anchor definitions
Cross-References
Internal and external references
URL Formats
Direct URLs
AsciiDoc automatically detects and converts URLs:- Checking HTTP status codes
- Following redirects (configurable)
- Using Puppeteer for JavaScript-rendered sites
Link Macros
Thelink: macro provides explicit link syntax:
Linkspector validates both the URL and local file paths in link macros.
Anchor Definitions
AsciiDoc supports four types of anchor definitions. Linkspector extracts all types for validation.1. Block Anchors
Standard anchor syntax using double brackets:- ID:
introduction,config-options - Description:
null,Configuration Options - Type:
block
2. Bibliography Anchors
Used in lists for bibliographic references:- ID:
citation-key,rfc2616 - Description:
null,RFC 2616 - Type:
bibliography
3. Inline Anchors
Concise syntax using hash symbol:- ID:
section-overview,important-note - Type:
inline
4. Anchor Macros
Inline anchor placement:- ID:
target-location,another-anchor - Text:
null,visible text - Type:
macro
Cross-References
Linkspector validates that cross-references point to existing anchors.Internal References (Shorthand)
Reference anchors within the same document:- Linkspector checks that
introductionanchor exists - Reports error if anchor is not defined
- Detects duplicate anchor definitions
External References (XRef Shorthand)
Reference anchors in other AsciiDoc files:- Checks that
other-file.adocandguide.adocexist - Verifies that referenced anchors (
section-name,installation) are defined in those files - Reports missing files or missing anchors
Linkspector auto-corrects missing
.adoc extensions: <<file#anchor>> becomes <<file.adoc#anchor>>.XRef Macros
Explicit cross-reference syntax:- Internal: Checks anchor exists in current file
- External: Validates file existence and anchor presence
Local File Links
Thelink: macro can reference local files:
- Linkspector checks file existence relative to the current document
- Reports missing files
- Handles HTML fragment syntax:
link:file.html#section[text]
Comment Handling
Linkspector correctly ignores links and anchors in comments:Single-line Comments
Multi-line Comment Blocks
- All content between
////delimiters is ignored - Single-line comments starting with
//are skipped - No validation errors for links/anchors in comments
Reference Validation
Linkspector provides specialized validation utilities for AsciiDoc references.Internal Reference Validation
Extract anchors
All anchor types are extracted from the document:
- Block anchors (
[[...]]) - Bibliography anchors (
[[[...]]]) - Inline anchors (
[#...]) - Anchor macros (
anchor:...[])
Extract internal references
Cross-references without file paths:
<<anchor>><<anchor, text>>xref:anchor[text]
External Reference Validation
Extract external references
Cross-references with file paths:
<<file.adoc#anchor>>xref:file.adoc#anchor[text]
Configuration
Enable AsciiDoc support by including file extensions in your configuration:.linkspector.yml
By default, Linkspector only checks
.md files. You must explicitly enable AsciiDoc extensions.Complete Example
Here’s a comprehensive AsciiDoc file demonstrating all link types:example.adoc
Error Messages
Linkspector provides clear error messages for AsciiDoc validation failures:Missing Internal Anchor
Duplicate Anchor
Missing External File
Missing Anchor in External File
Broken URL
Best Practices
Use descriptive anchor IDs
Use descriptive anchor IDs
Choose meaningful anchor names:
Avoid duplicate anchors
Avoid duplicate anchors
Linkspector detects duplicate anchors and reports them as errors. Use unique IDs throughout your documentation.
Use relative paths for local files
Use relative paths for local files
Reference files relative to the current document:
Include file extensions
Include file extensions
Always specify
.adoc extensions in cross-references:Test references after refactoring
Test references after refactoring
When reorganizing documentation, run Linkspector to catch broken references:
Implementation Details
Linkspector’s AsciiDoc parser is located in:lib/extract-asciidoc-comprehensive.js- Link and reference extractionlib/validate-asciidoc-references.js- Validation utilities
Extracted Reference Data
The parser provides structured data for validation:Validation Workflow
Limitations
- Include directives: Currently not resolved. External includes are not parsed.
- Conditional blocks: Content in
ifdef/ifndefblocks is always parsed. - Preprocessor directives: Attributes and substitutions are not evaluated.
- Inter-document attributes: Cross-file attribute references are not validated.
Troubleshooting
Anchors not detected
Anchors not detected
Ensure anchors use correct syntax:
[[id]]or[[id, description]]for block anchors[#id]for inline anchorsanchor:id[]for anchor macros
False positives on external references
False positives on external references
Verify:
- File paths are relative to the current document
- File extensions are included (
.adoc) - Referenced files exist in the repository
Comments still being checked
Comments still being checked
Bibliography anchors not working
Bibliography anchors not working
Bibliography anchors must be in list items:
Next Steps
CI/CD Integration
Automate AsciiDoc link checking in CI/CD
GitHub Actions
Check AsciiDoc files in GitHub workflows
// comment////delimiters on separate lines