"Extract heading" should transform Heading links into Internal links (or links break!)

Use case or problem

When right-clicking on a heading and selecting “Extract heading” so as to move the whole section into a separate file, heading links relative to the original file should be converted into internal links.

Currently, in the newly created file, links to sections of the original document (that were not moved to the new file) are broken.

Proposed solution

A solution would consist in prepending the original file name to Heading links contained in the section, if they refer to a section in the original file (but not if the subsection has been moved to the new file).

Current workaround

Currently, users can take relatively painful extra steps (if they remember to do it!) of converting, say [[#…]] into [[original file name#…]] if the links point to sections that were not moved. Each link must be checked manually: we need to check whether each header link refers to a section that was moved to the new file or not (which can be painful when the copied section is a bit long). That’s a perfect job for a computer!

Thanks!

1 Like

Another workaround might be (if it exists!) to first convert all the heading links in the original file to absolute links (i.e. prepend the file name to [[#…]] links). This is not ideal, though because we would lose the shorter and more legible of simple relative links of the form [[#…]—in addition to forcing users to remember to first do the conversion before extracting a heading into a new file.

There might already be a request for this if you haven’t searched (I haven’t searched either, but I know there’s at least been discussion about related issues).

I just saw a similar feature request/bug report, but it is the mirror of this one: it mentions that links in the original file that point to the extracted section should be updated, too (my original post is about updating links in the new file—I had missed that the same issue exists in the original file too).

1 Like