Skip to content

Commit

Permalink
- Include remark script statically in compiled HTML. Thank you Matt K…
Browse files Browse the repository at this point in the history
…antor

- As the generated file grows (around takes 850kB) when including the remark script,
this enhancement must be enabled with the `--include-remark` parameter
- Version changed to 1.0.3
  • Loading branch information
partageit committed Apr 5, 2016
1 parent 9fed7c0 commit 6087504
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ The same, enabling the document mode.
--document-mode, -d Generate slides from a document without slide separators (---) or annotations
--watch, -w Watch mode
--level Heading level to use as new slides (for example 3 is ###)
--include-remark -i Include Remark sources (around 850kB) into the generated document
```

## Notes
Expand All @@ -125,12 +126,16 @@ In other words, it is like markdown-to-slides, but for many documents at once, w
## Todo

- validate that md file exists
- store remark locally, or directly in the generated HTML document
- split big slides
- handle foot notes (from additional file?)

## Changelog

### Version 1.0.3

- Include remark script statically in compiled HTML. Thank you [Matt Kantor](https://github.com/mkantor)
- As the generated file grows (around takes 850kB) when including the remark script, this enhancement must be enabled with the `--include-remark` parameter

### Version 1.0.2

- It is possible to choose the heading level (default was 3, i.e. `###`) to split slides (#2)
Expand Down
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
var path = require('path');
var templateDir = __dirname + '/template';
var optimist = require('optimist')
.usage('Usage: $0 file.md')
.alias({
't': 'title',
'l': 'template',
Expand All @@ -11,7 +12,8 @@ var optimist = require('optimist')
'o': 'output-file',
'w': 'watch',
'v': 'version',
'd': 'document-mode'
'd': 'document-mode',
'i': 'include-remark'
})
.describe({
'title': 'Generated page title',
Expand All @@ -22,11 +24,13 @@ var optimist = require('optimist')
'output-file': 'Path to output file (stdout if not specified)',
'document-mode': 'Generate slides from a document without slide separators (---) or annotations',
'watch': 'Watch mode',
'level': 'Heading level to use as new slides (for example 3 is ###)'
'level': 'Heading level to use as new slides (for example 3 is ###)',
'include-remark': 'Include Remark sources (around 850kB) into the generated document'
})
.boolean('watch')
.boolean('document-mode')
.boolean('version')
.boolean('include-remark')
.default({
'style': path.resolve(templateDir + '/style.css'),
'template': path.resolve(templateDir + '/template.html'),
Expand Down
9 changes: 6 additions & 3 deletions lib/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ module.exports = function (argv, md) {
var style = fs.readFileSync(argv.style);
// Load script
var script = argv.script ? fs.readFileSync(argv.script) : '';
// Load remark source code.
var remarkPath = require.resolve('remark/out/remark');
var remarkSource = fs.readFileSync(remarkPath);
var remarkSource = '<script src="http://gnab.github.io/remark/downloads/remark-latest.min.js"></script>';
if (argv['include-remark']) {
// Load remark source code.
var remarkPath = require.resolve('remark/out/remark');
remarkSource = '<script>' + fs.readFileSync(remarkPath) + '</script>';
}
// Compile template and pipe it out.
var rendered = mustache.render(fs.readFileSync(argv.template, 'utf8'), {
content: content,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "markdown-to-slides",
"version": "1.0.2",
"version": "1.0.3",
"description": "Transform a markdown file to an HTML slideshow, using remark",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion template/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<textarea id="source">
{{{content}}}
</textarea>
<script>{{{remarkSource}}}</script>
{{{remarkSource}}}
<script>
var slideshow = remark.create();
</script>
Expand Down

0 comments on commit 6087504

Please sign in to comment.