markmv - v1.41.7
    Preparing search index...

    Class DependencyOrderJoinStrategy

    Join strategy that orders content based on dependency relationships.

    Uses topological sorting to arrange sections so that files are ordered according to their cross-reference dependencies. Files with no dependencies come first, followed by files that depend on them.

    Dependency-based joining

      const strategy = new DependencyOrderJoinStrategy({
    mergeFrontmatter: true,
    deduplicateLinks: true
    });

    const result = await strategy.join(sections);
    if (result.success) {
    console.log(`Joined ${result.sourceFiles.length} files in dependency order`);
    }

    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.

    • Joins sections in dependency order.

      Sections are topologically sorted so that a file comes after every file in the input that it depends on. Dependencies that are not among the input sections are ignored. If the dependencies are circular, a warning is recorded and the sections are ordered by their order field instead.

      Parameters

      • sections: readonly JoinSection[]

        The sections to join.

      Returns Promise<JoinResult>

      The joined result, or a failed result with errors populated if joining throws.

    • 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