3

I am writing a presentation in a markdown file referenced by Reveal.JS. I would like to import external file's source code in a markdown code block without having to do copy & paste. Ideally I would like to put a relative path to the file like I can do with an image.

Is it supported? I couldn't find it mentioned in the documentation.

Thanks.

Marco Bettiolo
  • 4,594
  • 6
  • 26
  • 35

2 Answers2

2

This is way old, but I found it while looking for a way to do the same thing...

There are some "helper packages" for Reveal.js that support including an external file. present has support for doing it in Markdown, and reveal-ck supports it in a number of other formats (but, as far as I can tell, not Markdown).

The author of present wrote up his approach in this post: Presentation tools for programmers: Reveal.js.

Community
  • 1
  • 1
dlu
  • 562
  • 8
  • 22
0

Regular Markdown does not support including content from external files, and I'm not aware of any Markdown extensions that add this feature.

You may be able to hack together a solution by concatenating files together, e.g.

01-intro1.md:

# My title

Some content, check out this example:

```

02-example1.js:

var foo = 'FOO';

03-intro2.md:

```

More content.

Generate your presentation file with cat 01-intro1.md 02-example1.js 03-intro2.md > presentation.md.

For more details, check out this question.

Community
  • 1
  • 1
Chris
  • 93,263
  • 50
  • 204
  • 189