AbstractCreates a merge strategy.
The defaults are automatic conflict resolution, a blank line between merged sections, no transclusions, frontmatter merging, structure preservation, the ![[{file}#{section}]] transclusion template and a maximum transclusion depth. Any supplied option overrides its default.
Options that override the defaults.
ProtectedoptionsThe effective options for this strategy: the supplied options layered over the defaults set in the constructor.
ProtectedcreateBuilds a transclusion reference from the configured transclusionTemplate.
The .md extension is dropped from the file name. Without a section, the #{section} part of the template is removed.
The file to reference.
Optionalsection: string
The section within the file, if any.
The transclusion text.
ProtecteddetectDetects whether transcluding the source into the target would create a loop.
A loop is reported when any existing transclusion mentions the target file name, or when the source and target are the same file.
The path of the file being merged into.
The path of the file that would be transcluded.
The transclusion references already in the target.
True when a loop would result.
ProtectedextractExtracts every markdown header from content.
The markdown content to scan.
One entry per header, in document order.
The header level, equal to the number of # characters.
The one-based line number of the header.
The header text, without the # markers.
ProtectedextractExtracts Obsidian transclusions (![[file]] or ![[file#section]]) from content.
The markdown content to scan.
One entry per transclusion, in document order.
The referenced file, with a .md extension added when the reference had none.
The one-based line number on which the transclusion appears.
The full transclusion text as written, for example ![[notes#intro]].
Optionalsection?: stringThe referenced section, when the reference includes one after #.
ProtectedfindFinds source headers that also exist in the target.
Headers match when their text is equal ignoring case and they have the same level.
The target's content.
The source's content.
One entry per colliding source header.
The text of the source header.
The one-based line of the header in the source.
The one-based line of the matching header in the target.
AbstractmergeMerges the content of a source file into a target file.
Each concrete strategy decides where the source content is placed. Conflicts are reported in the result rather than thrown, and a failure while merging is reported through errors with success set to false.
The full content of the file being merged into, including any frontmatter.
The full content of the file being merged from, including any frontmatter.
The path of the target file, used in conflict reports and transclusion loop checks.
The path of the source file, used in conflict reports and transclusion references.
The merged content and frontmatter, the files involved, and any conflicts, warnings, errors and created transclusions.
ProtectedmergeMerges the frontmatter of the target and source.
When only one side has frontmatter it is returned unchanged. Otherwise, for keys present on both sides the target's value wins, except that tags, categories and keywords are combined as de-duplicated lists when both sides hold lists.
The target's raw frontmatter block, or an empty string.
The source's raw frontmatter block, or an empty string.
The merged frontmatter block, or an empty string when neither side has any.
Abstract base class for all merge strategies.
Provides common functionality for merging markdown files including transclusion handling, conflict detection, and frontmatter management. Concrete strategies implement specific merging approaches.
Example
Implementing a custom merge strategy