markmv - v1.41.7
    Preparing search index...

    Class BaseJoinStrategyAbstract

    Abstract base class for all join strategies.

    Provides common functionality for joining markdown files including frontmatter merging, conflict detection, and link deduplication. Concrete strategies implement specific ordering algorithms.

    Implementing a custom join strategy

      class CustomJoinStrategy extends BaseJoinStrategy {
    async join(sections: JoinSection[]): Promise<JoinResult> {
    // Custom ordering logic
    const orderedSections = this.customSort(sections);
    return await Promise.resolve(this.buildResult(orderedSections));
    }
    }

    Hierarchy (View Summary)

    Index

    The effective options for this strategy: the supplied options layered over the defaults set in the constructor.

    • Removes repeated links from combined content.

      The first occurrence of each markdown link (same text and target) and each bare URL is kept. A repeated markdown link is replaced by its link text (or its URL when the text is empty), and a repeated bare URL is deleted.

      Parameters

      • content: string

        The combined document content.

      Returns { content: string; removedLinks: string[] }

      The de-duplicated content and the occurrences that were removed.

      • content: string

        The content with repeated links replaced or removed.

      • removedLinks: string[]

        Each removed occurrence exactly as it appeared, in document order.

    • Detects conflicts between sections.

      Reports a duplicate-headers conflict for each header (compared case-insensitively) that appears in more than one section, and a frontmatter-merge conflict for each frontmatter key present in more than one section.

      Parameters

      • sections: readonly JoinSection[]

        The sections to compare.

      Returns JoinConflict[]

      One conflict per duplicated header or frontmatter key, naming the files involved.

    • Extracts the text of every markdown header in a document.

      Parameters

      • content: string

        The markdown content to scan.

      Returns string[]

      The header texts in document order, without the leading # markers.

    • Extracts a title from a document.

      A title: frontmatter line takes precedence, with any quote characters removed. Otherwise the text of the first markdown header in the content is used.

      Parameters

      • content: string

        The document body to scan for a header.

      • Optionalfrontmatter: string

        The raw frontmatter block, if the document has one.

      Returns string | undefined

      The title, or undefined when there is neither a frontmatter title nor a header.

    • Orders the sections and combines them into a single document.

      Each concrete strategy decides the section order. Conflicts between sections are reported in the result rather than thrown, and a failure while joining is reported through errors with success set to false.

      Parameters

      • sections: readonly JoinSection[]

        The sections to join, one per source file.

      Returns Promise<JoinResult>

      The combined content, merged frontmatter (when enabled), the source files in their final order, and any conflicts, warnings, errors and removed duplicate links.

    • Merges the frontmatter blocks of several sections into one block.

      The tags, categories and keywords keys are collected across all sections as de-duplicated lists. Differing title values are combined with &. Every other key keeps the first value found, and a purely numeric value is written as a number.

      Parameters

      • sections: readonly JoinSection[]

        The sections whose frontmatter is merged, in output order.

      Returns string

      A --- delimited frontmatter block, or an empty string when no section supplies any keys.

    • Returns title unless it is undefined or the empty string, in which case filePath is used. An empty title is treated as "no title supplied" rather than a meaningful value to sort or display by.

      Parameters

      • title: string | undefined
      • filePath: string

      Returns string