Marco Bettiolo
Marco Bettiolo

Reputation: 5171

Display contents of a file with code using markdown and revealjs

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.

Upvotes: 3

Views: 5680

Answers (2)

dlu
dlu

Reputation: 791

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.

Upvotes: 2

Chris
Chris

Reputation: 137075

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.

Upvotes: 1

Related Questions