Doing Merge where order is important?

Things I have tried

I have tried using Note Composer to do a merge between two files. it appears to do the equivalent of a concatenation when merging the two files. Not what I’m looking for.

What I’m trying to do

I’m looking to merge two notes, however the methods described in this forum don’t acheive the result I’m looking for. I.E. using Note composer’s merge function doesn’t provide the result I’m looking for.

Here’s the situation I have.

I have two files. FILE 1, and FILE 2.

FILE 1 text is as follows:

# main heading 1

## sub-heading 1-a

some text here describing heading 2, etc.

### sub-sub heading 1-b
some text here about heading 1-b

1. a list 
2. relating to 
3. heading 3-a


## sub-heading 2-a

some information

### sub-sub heading 2-b

some text about sub-sub heading 2-b

some notes to self about sub-sub heading 2-b.
etc. 
etc.

FILE 2 text is as follows:


# main heading 1

## sub-heading 1-a

some text here describing heading 2, etc.

### sub-sub heading 1-b
some text here about heading 1-b

## sub-heading 4-a
some text about heading 4-a

## sub-heading 2-a

some information

### sub-sub heading 2-b

some text about sub-sub heading 2-b


## sub-heading 3-a
some text about sub heading 3-a

I want to merge File 1 and File 2 in accordance to these requirements:

  • Content and line text order of file 1 is preserved,
  • Items in file 2 that don’t exist in File 1 are added to file 1 in the relative same line order as FILE 2.

I.E. The final merged version should look like this:

# main heading 1

## sub-heading 1-a

some text here describing heading 2, etc.

### sub-sub heading 1-b
some text here about heading 1-b

1. a list 
2. relating to 
3. heading 3-a

## sub-heading 4-a
some text about heading 4-a

## sub-heading 2-a

some information

### sub-sub heading 2-b

some text about sub-sub heading 2-b

some notes to self about sub-sub heading 2-b.
etc. 
etc.

## sub-heading 3-a
some text about sub heading 3-a

I’ll re-iterate. I do not want to simply just concatenate file 2 onto file 1. I.E. Take notice how the text ‘## sub-heading 4-a’ is placed in the final, simulated, merged version of the text.

How do I accomplish this type of merge? Is there a way to do this in obsidian? Is there someway I can accomplish this with some sort of “fancy” use of git’s merge abilities?

I don’t think there’s a way to do it in Obsidian. (Obsidian Sync is able to merge when a file has changed on >1 end of the sync, but trying to take advantage of that would be hacky and inconvenient.)

I’d use a separate app, like Meld on Linux or CompareMerge on Mac.