Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Markdown: Reference to section from another file

Tags:

markdown

I have two markdown files: a parent.md and a child.md.

So parent.md:

# Main section

## sub-section

I'd like to make reference to ## sub-section from child.md.

Any ideas?

like image 647
Jordi Avatar asked Jul 05 '18 09:07

Jordi


People also ask

Can markdown include other files?

You can now attach files, including images, to markdown files while you're editing them in the web. This works just like file attachments in issues and pull requests and supports the same file types.

How do you create a table of contents in markdown?

Press CTRL + SHIFT + P. Select Markdown: Create Table of Contents.


2 Answers

In MarkDown, reference is possible using hyperlink :

#  Main section

##  [sub-section](./child.md#sub-section)    
##  [sub-section](/child.md#sub-section)
##  [sub-section](child.md#sub-section)

Unfortunately the direct embedding of another Markdown file is not possible

Alternatives

An alternative is the use of an incision from a capture of the other file:

#  Main section

##  sub-section

![ImageTheOtherMarkdown](Screent.png)
like image 189
Nicolás Alarcón Rapela Avatar answered Oct 09 '22 17:10

Nicolás Alarcón Rapela


What worked for me is in parent.md:

[link](./file.md#section-name) // note the dash!

In child.md:

## ...
## section name

I tested this on my local via JetBrains IDE.

like image 37
maraps Avatar answered Oct 09 '22 17:10

maraps