Skip to content

ExtractorDelegator

The ExtractorDelegator class manages the delegation of content extraction to specific extractors. It itself is an extractor.

Extends

  • BaseExtractor

Methods

cleanContents()

cleanContents(contents): string

Cleans the contents of a file by removing frontmatter, code blocks, and other irrelevant content.

Parameters

ParameterTypeDescription
contentsstringThe content string to be cleaned.

Returns

The cleaned content string.

Inherited from

BaseExtractor.cleanContents

Source

source/extract/BaseExtractor.ts:133


extract()

extract(
file?,
metadata?,
strategy?): Promise<FileContents[]>

Extracts content from a file based on the specified strategy and evergreen status. This method delegates to specific extractors depending on the strategy provided. If no strategy is specified, it defaults to extracting the raw contents of the file, performing embed replacements, and cleaning the contents.

Parameters

ParameterTypeDescription
file?TFileThe file from which to extract content.
metadata?CachedMetadataThe cached metadata of the file.
strategy?StrategyMetadataThe strategy to use for content extraction (optional).

Returns

A Promise that resolves to an array of FileContents objects.

Overrides

BaseExtractor.extract

Source

source/extract/ExtractorDelegator.ts:86


getEmbedContent()

getEmbedContent(reference): Promise<string>

Retrieves the content of an embedded block or section from a file.

Parameters

ParameterTypeDescription
referenceReferenceCacheThe reference cache object containing the link to the embedded content.

Returns

A Promise that resolves to the content of the embedded block or section.

Inherited from

BaseExtractor.getEmbedContent

Source

source/extract/BaseExtractor.ts:153


replaceEmbeds()

replaceEmbeds(contents, metadata): Promise<object>

Replaces embed references in the content with the actual embedded content.

This method iterates over each embed reference found in the metadata, retrieves the content for that reference, and replaces the reference in the original content with the retrieved content. Block references within the embed content are also substituted for markers. It adjusts the offset for each subsequent replacement to account for the change in content length after each replacement.

Parameters

ParameterTypeDescription
contentsstringThe original content containing embed references.
metadataCachedMetadataThe metadata object containing embeds and their positions.

Returns

A Promise that resolves to an object containing the modified content and an array of block reference substitutions.

Inherited from

BaseExtractor.replaceEmbeds

Source

source/extract/BaseExtractor.ts:202


substituteBlockReferences()

substituteBlockReferences(title, contents): object

Substitutes block references within the content. This method scans the provided content for block reference markers (e.g., ^blockid) and replaces them with Obsidian-style block reference links (![[title#^blockid]]). It does something similar for headings. It also generates and substitutes temporary placeholders for these block references which can be used for further processing.

Parameters

ParameterTypeDescription
titlestringThe title of the file where the block references are located.
contentsstringThe content string containing the block references to be substituted.

Returns

An object containing the array of block reference substitutions and the modified content.

contents
contents: string;
substitutions
substitutions: BlockRefSubstitution[];

Inherited from

BaseExtractor.substituteBlockReferences

Source

source/extract/BaseExtractor.ts:78


Generated using typedoc-plugin-markdown and TypeDoc