GithubHelp home page GithubHelp logo

bespoke-markdown's Introduction

Build Status Coverage Status

bespoke-markdown

Allows you to use [(GitHub flavored) Markdown][gfm] to author your bespoke.js presentation. There are 4 ways to use this plugin and they are described on the demo page. [gfm]: https://help.github.com/articles/github-flavored-markdown

Download

Download the production version or the development version, or use a package manager.

Usage

There are 3 steps to using this plugin.

  1. Including and initializing the plugin
  2. Including a stylesheet for code highlighting
  3. Authoring the presentation using Markdown

1. Including and initializing the plugin

This plugin is shipped in a UMD format, meaning that it is available as a CommonJS/AMD module or browser global.

For example, when using CommonJS modules:

var bespoke = require('bespoke'),
    markdown = require('bespoke-markdown');

bespoke.from('#presentation', [
  markdown()
]);

If using browser globals:

bespoke.from('#presentation', [
  bespoke.plugins.markdown()
]);

2. Stylesheet for code highlighting

If you want code highlighting, you also need to include a stylesheet from [highlight.js][hljs]. One option to include it is via the dependencies of this plugin, as highlight.js is a dependency of bespoke-markdown. [hljs]: https://highlightjs.org/

In that case, you can include it by:

<link rel="stylesheet" type="text/css" href="node_modules/bespoke-markdown/node_modules/highlight.js/styles/THEME_NAME.css" />

You can choose any theme from highlight.js and put it instead of THEME_NAME. Some themes are:

  • default.css
  • monokai_sublime.css
  • sublime.css
  • github.css

3. Authoring presentation using Markdown

Just by including the plugin code and initializing bespoke with it will allow writing the content of the slides in Markdown. You can use a markup similar to the following:

<article>
  <section>
# Title
This is **markdown content**.
  </section>
</article>

You can also write Markdown content in external files. You can do it for the whole presentation or for specific slides. To mark a slide to be rendered using Markdown, you need to add the data-markdown="path-to-file.md" attribute to the presentation HTML element, like so:

<article data-markdown="presentation.md"></article>

Or, you can add it to specific slides only:

<article>
  <section data-markdown="slide-1.md"></section>
  <section>
    <p>A slide authored in HTML</p>
  </section>
  <section data-markdown="slide-3.md"></section>
</article>

You can split the .md file in multiple slides by using "---" to separate them. For instance, presentation.md:

This is the first slide
---
Second slide
---
And third!

Additionally, you can mix slides authored in HTML and in Markdown. To mark a slide to have its contents rendered as Markdown, we also use the data-markdown attribute, but without a value (or with an empty value, i.e., data-markdown=""). Check the example:

<article>
  <section data-markdown>
    # Title 1
    This is a slide authored in Markdown.
  </section>
  <section data-markdown="">
    # Title 2
    This is also a slide authored in Markdown.
  </section>
  <section>
    <h1>Title 3</h1>
    <p>This is a slide authored in HTML.</p>
  </section>
</article>

Package managers

npm

$ npm install bespoke-markdown

Bower

$ bower install bespoke-markdown

Credits

This plugin was built with generator-bespokeplugin.

License

MIT License

bespoke-markdown's People

Contributors

aaronpowell avatar fegemo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

bespoke-markdown's Issues

The current test is failing

Probably because of the use of GitHub Flavored Markdown as the default on marked, now the h1..h6 tags have auto generated ids, which is breaking the tests.

Test output:

INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket 6-tfItarL76cEgTKcr1D
PhantomJS 1.9.7 (Windows 7) bespoke-markdown deck.slide should have parsed the slide from markdown to html FAILED
        Expected '<h1 id="0">0</h1>
        ' to be '<h1>1</h1>'.

I can write a PR to change the test and fix this.

Support the use of an external Markdown file instead of using markdown inside html

Hi,

I'd like to know if it's ok to work on a feature to support the use of an external Markdown file to contain the whole presentation instead of supporting the use of markdown for the content of the slides.

My motivation is to have the full content of the bespoke presentation in Markdown format so we can, for example, use it as README.md and make the content of the presentation available as both a bespoke presentation and a README.md for access through GitHub, for example.

I'm inspired by the markdown plugin for revealjs, which allows exactly that. For example, I created a presentation using revealjs + markdown plugin to achieve that:

Highlight.js not found when using the plugin

This issue was introduced on the PR 4: #4
Basically, I included highlight.js as a devDependency, but it is a production dependency.

The console message:

events.js:72
throw er; // Unhandled 'error' event
^
Error: module "highlight.js" not found from "C:\c\node_modules\bespoke-markdown\lib\bespoke-markdown.js"
at notFound (C:\c\node_modules\gulp-browserify\node_modules\browserify\index.js:803:15)
at C:\c\node_modules\gulp-browserify\node_modules\browserify\index.js:754:23
at C:\c\node_modules\gulp-browserify\node_modules\browserify\node_modules\browser-resolve\index.js:185:24
at C:\c\node_modules\gulp-browserify\node_modules\browserify\node_modules\resolve\lib\async.js:44:14
at process (C:\c\node_modules\gulp-browserify\node_modules\browserify\node_modules\resolve\lib\async.js:113:43)
at C:\c\node_modules\gulp-browserify\node_modules\browserify\node_modules\resolve\lib\async.js:122:21
at load (C:\c\node_modules\gulp-browserify\node_modules\browserify\node_modules\resolve\lib\async.js:54:43)
at C:\c\node_modules\gulp-browserify\node_modules\browserify\node_modules\resolve\lib\async.js:60:22
at C:\c\node_modules\gulp-browserify\node_modules\browserify\node_modules\resolve\lib\async.js:16:47
at Object.oncomplete (fs.js:107:15)

New PR coming... Sorry about that!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.