TaskValidator.Parsers.ReferenceResolver (TaskValidator v0.9.3)

View Source

Handles reference resolution and validation in TaskList documents.

References allow for content reuse and reduce file size by 60-70%. This module validates reference integrity without expanding them, as the TaskValidator only checks that references exist.

Summary

Functions

Expands a single reference placeholder with its definition.

Extracts reference definitions from markdown lines.

Finds all reference placeholders used in the content.

Gets statistics about reference usage in a TaskList.

Validates reference integrity for a TaskList.

Validates that all reference placeholders have corresponding definitions.

Functions

expand_reference(content, references)

@spec expand_reference(String.t(), map()) :: String.t()

Expands a single reference placeholder with its definition.

This function is provided for completeness but is not used by the TaskValidator, which only validates reference existence.

extract_references(lines)

@spec extract_references([String.t()]) :: {:ok, map()}

Extracts reference definitions from markdown lines.

Reference definitions follow the format:

{{reference-name}} or ## #{{reference-name}}

Returns a map where keys are reference names and values are the content lines.

find_reference_usages(lines)

@spec find_reference_usages([String.t()]) :: [{String.t(), integer()}]

Finds all reference placeholders used in the content.

Returns a list of {reference_name, line_number} tuples for all {{reference-name}} placeholders found in the document.

reference_stats(task_list)

@spec reference_stats(TaskValidator.Core.TaskList.t()) :: map()

Gets statistics about reference usage in a TaskList.

validate_reference_integrity(lines, references)

@spec validate_reference_integrity([String.t()], map()) :: :ok | {:error, String.t()}

Validates reference integrity for a TaskList.

This is the main validation function that ensures all used references have corresponding definitions.

validate_references(task_list)

Validates that all reference placeholders have corresponding definitions.

This function does NOT expand references - it only validates that every {{reference-name}} placeholder has a matching ## #{{reference-name}} definition.