Skip to content

Instantly share code, notes, and snippets.

@jcham
Last active January 9, 2018 07:51
Show Gist options
  • Save jcham/c82121c4e898effed7687a31fe2030f1 to your computer and use it in GitHub Desktop.
Save jcham/c82121c4e898effed7687a31fe2030f1 to your computer and use it in GitHub Desktop.

Creating a hosted Slideshow using a Gist, Markdown, and remark.js.

Why? because it is the quickest way to make a code-heavy slideshow that's easy to present and host.


Step 1


Step 2: Create a Markdown file with your slides

  • Add a Markdown file to the Gist, we'll call it _slides.md but you can call it anything. We start it with _ because we want github.com to show it first.

Step 2: Edit the file with Markdown

  • Use standard Markdown syntax.
  • The only change is that you separate each slide by putting in three dashes --- which in Markdown is usually used to add an Horizontal Line <HR/>.

Step 3: Add the template file to the Gist

  • Add a template index.html file to the Gist. We call it index.html so that our Gist-to-website renderer will display it by default.
  • The contents should be this. Among other things it contains this:
<script>
  var slideshow = remark.create({ 
    sourceUrl: './_slides.md',
    highlightLines: true,
    highlightSpans: /(.*)(\/\/\*)/g,
  });
</script>
  • Note the name of the sourceUrl should be the name of your Markdown file.

  • At this point you should have 2 files in your Gist, one _slides.md and one index.html.


Step 4: Present!

  • Once you save the Gist, you should get the URL for it (something like https://gist.github.com/jcham/c82121c4e898effed7687a31fe2030f1).
  • There's a number of services which given a Gist will present it as a website. One of them is bl.ocks.org.
  • To use bl.ocks.org just change the hostname of the above URL to bl.ocks.org, so:
https://gist.github.com/jcham/c82121c4e898effed7687a31fe2030f1

becomes:

https://bl.ocks.org/jcham/c82121c4e898effed7687a31fe2030f1
  • Note that because of caching, utilities like bl.ocks.org sometimes take a few minute to update their contents.

Bonus: Syntax coloring and Highlighting Code

  • remark.js let's us specify the Programming Language of the code, just use the standard 3 backticks followed by the name of the language like ```ruby.
  • It's also sometimes useful to highlights part of the code you're talking about.
  • remark.js allows us to specify a pattern in its options that will cause the line to be colored yellow. You can edit this in the index.html file.
  • In this example, we set the pattern to //* so that the line stays valid Javascript, but you can set it to anything.
var slideshow = remark.create({ 
    sourceUrl: './_slides.md',
    highlightLines: true,
    highlightSpans: /(.*)(\/\/\*)/g,   //* This line is yellow
});
<!DOCTYPE html>
<html>
<head>
<title>Remark</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<textarea id="source">
</textarea>
<script src="https://github.com/cardinalblue/remark/releases/download/v0.15.0_beta1/remark.min.js">
</script>
<script>
var slideshow = remark.create({
sourceUrl: './_slides.md',
highlightLines: true,
highlightSpans: /(.*)(\/\/\*)/g,
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment