1.4.3 • Published 9 years ago

bespoke-meta-markdown v1.4.3

Weekly downloads
3
License
-
Repository
github
Last release
9 years ago

bespoke-meta-markdown

Prefix slides with YAML meta data, configure behaviour based on the meta data.

Usage

Simply drop it in as a replacement for bespoke-marked,

var markdown = require('bespoke-meta-markdown');
bespoke.from('article', [
  markdown(config)
]);

Config

Default config:

var defaults = {
  master: function (slide, value) {
    slide.classList.add(value);
  }
};  

To take advantage of this default behavior insert YAML data in a slide

---

<!--
master: myClass
-->

# title of slide

* bullet
* list

---

To configure your own behavior, simply define methods on the configuration object

var markdown = require('bespoke-meta-markdown');
bespoke.from('article', [
  markdown({
    copyright: function(slide, info) {
      slide.innerHTML += '<p>&copy; ' + info.owner + ' ' + info.year  + '</p>';
    }
  })
]);

To turn off default behaviour set master to null

var markdown = require('bespoke-meta-markdown');
bespoke.from('article', [
  markdown({master: null});
]);

The this context of each configuration method is the bespoke deck object, for cases where YAML configuration could affect all slides:

var markdown = require('bespoke-meta-markdown');
bespoke.from('article', [
  markdown({
    skip: function (slide, bool) {
      if (!bool) {return;}
      var deck = this;
      deck.slides.splice(deck.slides.indexOf(slide), 1);
      deck.parent.removeChild(slide);
    }
  })
]);

Package managers

npm

$ npm install bespoke-meta-markdown

Graceful Reloads

As of 1.3.x bespoke-meta-markdown supplies a reload method which allows slides loaded from markdown to be reloaded in place, instead of a full refresh.

The reload method is supplied on the function object returned when the exported function is called.

require('bespoke-meta-markdown') 
  => function metaMarkdown(config) 
    => function bespokePlugin(deck, ...)
    #reload function(file, LR)

The idea is to tie it into live reload

var markdown = require('bespoke-meta-markdown');
var md = markdown();
bespoke.from('article', [md]);

LiveReload.addPlugin(MarkdownPlugin)  

function MarkdownPlugin(window, host) {
  this.window = window;
  this.host = host;
}

MarkdownPlugin.prototype.reload = function (path, opts) {
  path = path.split('/');
  var file = path[path.length-1];
  if (file.split('.')[1] !== 'md') { return false; }
  md.reload(file, this); //<-- using the bespoke-meta-markdown reload method
  return true;
}

Credits

This plugin was built with generator-bespokeplugin.

License

MIT License

1.4.3

9 years ago

1.4.2

9 years ago

1.4.1

9 years ago

1.4.0

9 years ago

1.3.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago