Permalink
Browse files

Formatting

  • Loading branch information...
webpro committed Jul 25, 2018
1 parent e98c7e9 commit 00fb23fe2bc86d9e5cab81896ab4a2d455f05a5e
Showing with 132 additions and 102 deletions.
  1. +10 −10 CODE_OF_CONDUCT.md
  2. +17 −17 CONTRIBUTING.md
  3. +25 −25 README.md
  4. +9 −3 bin/cli.js
  5. +1 −2 lib/print.js
  6. +12 −8 test/preproc.js
  7. +58 −37 test/render.spec.js
@@ -8,19 +8,19 @@ In the interest of fostering an open and welcoming environment, we as contributo

Examples of behavior that contributes to creating a positive environment include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

@@ -6,12 +6,12 @@ This project has a [Contributor Covenant Code of Conduct](./CODE_OF_CONDUCT.md).

## ❤️ Ways to Contribute

* Blog or tweet about the project
* Improve documentation
* Fix a bug
* Implement a new feature
* Discuss potential ways to improve project
* Improve existing implementation, performance, etc.
- Blog or tweet about the project
- Improve documentation
- Fix a bug
- Implement a new feature
- Discuss potential ways to improve project
- Improve existing implementation, performance, etc.

## 🛎 Questions

@@ -23,22 +23,22 @@ Please put some effort in requesting a new feature. If someone else is going to

In case you've encountered a bug, please make sure:

* You are using the [latest version](https://github.com/webpro/reveal-md/releases).
* You have read the [documentation](https://github.com/webpro/reveal-md/blob/master/README.md) first, and double-checked your configuration.
* In your issue description, please include:
* What you expected to see, and what happened instead.
* Your operating system and other environment information.
* As much information as possible, such as the command and configuration used.
* Interesting logs with `DEBUG=reveal-md reveal-md [...]`. \* All steps to reproduce the issue.
- You are using the [latest version](https://github.com/webpro/reveal-md/releases).
- You have read the [documentation](https://github.com/webpro/reveal-md/blob/master/README.md) first, and double-checked your configuration.
- In your issue description, please include:
- What you expected to see, and what happened instead.
- Your operating system and other environment information.
- As much information as possible, such as the command and configuration used.
- Interesting logs with `DEBUG=reveal-md reveal-md [...]`. \* All steps to reproduce the issue.

## 🎁 Pull Requests

Pull requests are welcome! Please keep the following in mind:

* See below for instructions on how to set up the project on your machine.
* To match the existing code styling, use `npm run prettier` before committing code.
* Make sure the tests pass (run `npm test`). Your changes probably deserve new tests as well.
* Remember that this project is cross-platform compatible (macOS, Windows, Linux), and that it runs in different versions of Node.
- See below for instructions on how to set up the project on your machine.
- To match the existing code styling, use `npm run prettier` before committing code.
- Make sure the tests pass (run `npm test`). Your changes probably deserve new tests as well.
- Remember that this project is cross-platform compatible (macOS, Windows, Linux), and that it runs in different versions of Node.

Unsure about whether you should open a pull request? Feel free to discuss it first in a ticket.

@@ -22,25 +22,25 @@ reveal-md https://raw.githubusercontent.com/webpro/reveal-md/master/demo/a.md

## Features

* [Markdown](#markdown)
* [Theme](#theme)
* [Highlight Theme](#highlight-theme)
* [Custom Slide Separators](#custom-slide-separators)
* [Custom Slide Attributes](#custom-slide-attributes)
* [reveal-md Options](#reveal-md-options)
* [Reveal.js Options](#revealjs-options)
* [Speaker Notes](#speaker-notes)
* [YAML Front Matter](#yaml-front-matter)
* [Live Reload](#live-reload)
* [Custom Scripts](#custom-scripts)
* [Custom CSS](#custom-css)
* [Pre-process Markdown](#pre-process-markdown)
* [Print to PDF](#print-to-pdf)
* [Static Website](#static-website)
* [Disable Auto-open Browser](#disable-auto-open-browser)
* [Directory Listing](#directory-listing)
* [Custom Port](#custom-port)
* [Custom Template](#custom-template)
- [Markdown](#markdown)
- [Theme](#theme)
- [Highlight Theme](#highlight-theme)
- [Custom Slide Separators](#custom-slide-separators)
- [Custom Slide Attributes](#custom-slide-attributes)
- [reveal-md Options](#reveal-md-options)
- [Reveal.js Options](#revealjs-options)
- [Speaker Notes](#speaker-notes)
- [YAML Front Matter](#yaml-front-matter)
- [Live Reload](#live-reload)
- [Custom Scripts](#custom-scripts)
- [Custom CSS](#custom-css)
- [Pre-process Markdown](#pre-process-markdown)
- [Print to PDF](#print-to-pdf)
- [Static Website](#static-website)
- [Disable Auto-open Browser](#disable-auto-open-browser)
- [Directory Listing](#directory-listing)
- [Custom Port](#custom-port)
- [Custom Template](#custom-template)

### Markdown

@@ -304,12 +304,12 @@ reveal-md slides.md --listing-template my-listing-template.html

## Related Projects & Alternatives

* [Slides](https://slides.com/) is a place for creating, presenting and sharing slide decks.
* [Sandstorm Hacker Slides](https://github.com/jacksingleton/hacker-slides) is a simple app that combines Ace Editor and RevealJS.
* [Tools](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware#tools) in the Plugins, Tools and Hardware section of Reveal.js.
* [Org-Reveal](https://github.com/yjwen/org-reveal) exports Org-mode contents to Reveal.js HTML presentation.
* [DeckTape](https://github.com/astefanutti/decktape) is a high-quality PDF exporter for HTML5 presentation frameworks.
* [GitPitch](https://gitpitch.com) generates slideshows from PITCHME.md found in hosted Git repos.
- [Slides](https://slides.com/) is a place for creating, presenting and sharing slide decks.
- [Sandstorm Hacker Slides](https://github.com/jacksingleton/hacker-slides) is a simple app that combines Ace Editor and RevealJS.
- [Tools](https://github.com/hakimel/reveal.js/wiki/Plugins,-Tools-and-Hardware#tools) in the Plugins, Tools and Hardware section of Reveal.js.
- [Org-Reveal](https://github.com/yjwen/org-reveal) exports Org-mode contents to Reveal.js HTML presentation.
- [DeckTape](https://github.com/astefanutti/decktape) is a high-quality PDF exporter for HTML5 presentation frameworks.
- [GitPitch](https://gitpitch.com) generates slideshows from PITCHME.md found in hosted Git repos.

## License

@@ -13,7 +13,10 @@ program
.description('See https://github.com/webpro/reveal-md for more details.')
.option(' --title <title>', 'Title of the presentation')
.option(`-s, --separator <separator>`, `Slide separator [default: 3 dashes (---) surrounded by two blank lines]`)
.option('-S, --vertical-separator <separator>', 'Vertical slide separator [default: 4 dashes (----) surrounded by two blank lines]')
.option(
'-S, --vertical-separator <separator>',
'Vertical slide separator [default: 4 dashes (----) surrounded by two blank lines]'
)
.option('-t, --theme <theme>', `Theme [default: ${defaults.theme}]`)
.option(' --highlight-theme <theme>', `Highlight theme [default: ${defaults.highlightTheme}]`)
.option(' --css <files>', 'CSS files to inject into the page')
@@ -23,14 +26,17 @@ program
.option(' --listing-template <filename>', 'Template file for listing')
.option(' --print [filename]', 'Print to PDF file')
.option(' --static [dir]', 'Export static html to directory [_static]. Incompatible with --print.')
.option(' --static-dirs <dirs>', 'Extra directories to copy into static directory. Only used in conjunction with --static.')
.option(
' --static-dirs <dirs>',
'Extra directories to copy into static directory. Only used in conjunction with --static.'
)
.option('-w, --watch', `Watch for changes in markdown file and livereload presentation`)
.option(' --disable-auto-open', 'Disable auto-opening your web browser')
.option(' --host <host>', `Host [default: ${defaults.host}]`)
.option(' --port <port>', `Port [default: ${defaults.port}]`)
.parse(process.argv);

if(program.args.length > 2) {
if (program.args.length > 2) {
program.help();
}

@@ -10,8 +10,7 @@ try {
} catch (err) {}

module.exports = function print(options) {

if(!puppeteer) {
if (!puppeteer) {
console.warn(`Puppeteer unavailable, unable to generate PDF file.`);
return;
}
@@ -1,9 +1,13 @@
module.exports = (markdown, options) => new Promise((resolve, reject) => {
const output = markdown.split('\n').map((line, index) => {
if(!/^#/.test(line) || index === 0) return line;
const is_vertical = /#\^/.test(line);
return (is_vertical ? '\n----\n\n' : '\n---\n\n') + line.replace('#^', '#');
}).join('\n');
module.exports = (markdown, options) =>
new Promise((resolve, reject) => {
const output = markdown
.split('\n')
.map((line, index) => {
if (!/^#/.test(line) || index === 0) return line;
const is_vertical = /#\^/.test(line);
return (is_vertical ? '\n----\n\n' : '\n---\n\n') + line.replace('#^', '#');
})
.join('\n');

return resolve(output);
});
return resolve(output);
});
@@ -5,23 +5,26 @@ const render = require('../lib/render');
const markdown = fs.readFileSync('demo/a.md').toString();

describe('render', () => {

it('should render basic template', () => {
return render.render('', {}).then(actual => {
expect(actual).toContain('<title>reveal-md</title>');
expect(actual).toContain('<link rel="stylesheet" href="/css/theme/black.css"');
expect(actual).toContain('<link rel="stylesheet" href="/css/highlight/zenburn.css"');
expect(actual).toContain('<link rel="stylesheet" href="/css/print/paper.css" type="text/css" media="print">');
expect(actual).toContain('<div class="slides"><section data-markdown><script type="text/template"></script></section></div>');
expect(actual).toContain(
'<div class="slides"><section data-markdown><script type="text/template"></script></section></div>'
);
expect(actual).toContain('<script src="/js/reveal.js"></script>');
expect(actual).toContain('{ src: \'/plugin/markdown/markdown.js\'');
expect(actual).toContain("{ src: '/plugin/markdown/markdown.js'");
expect(actual).toContain('var options = {};');
});
});

it('should render markdown content', () => {
return render.render('# header', {}).then(actual => {
expect(actual).toContain('<div class="slides"><section data-markdown><script type="text/template"># header</script></section></div>');
expect(actual).toContain(
'<div class="slides"><section data-markdown><script type="text/template"># header</script></section></div>'
);
});
});

@@ -79,65 +82,83 @@ describe('render', () => {
});

describe('parseSlides', () => {

it('should render slides split by horizontal separator', () => {
render.parseSlides('Slide A\n\n---\n\nSlide B', {}).then(actual => {
expect(actual.slides).toEqual('' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">\nSlide B</script></section>');
expect(actual.slides).toEqual(
'' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">\nSlide B</script></section>'
);
});
});

it('should render sub slides split by vertical separator', () => {
render.parseSlides('Slide A\n\n---\n\nSlide B\n\n----\n\nSlide C', {}).then(actual => {
expect(actual.slides).toEqual('' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section >' +
'<section data-markdown><script type="text/template">\nSlide B\n</script></section>' +
'<section data-markdown><script type="text/template">\nSlide C</script></section>' +
'</section>');
expect(actual.slides).toEqual(
'' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section >' +
'<section data-markdown><script type="text/template">\nSlide B\n</script></section>' +
'<section data-markdown><script type="text/template">\nSlide C</script></section>' +
'</section>'
);
});
});

it('should render slides split by custom separators', () => {
render.parseSlides('Slide A\n\n\nSlide B\n\nSlide C', { separator: '\n\n\n', verticalSeparator: '\n\n' }).then(actual => {
expect(actual.slides).toEqual('' +
'<section data-markdown><script type="text/template">Slide A</script></section>' +
'<section >' +
'<section data-markdown><script type="text/template">Slide B</script></section>' +
'<section data-markdown><script type="text/template">Slide C</script></section>' +
'</section>');
});
render
.parseSlides('Slide A\n\n\nSlide B\n\nSlide C', { separator: '\n\n\n', verticalSeparator: '\n\n' })
.then(actual => {
expect(actual.slides).toEqual(
'' +
'<section data-markdown><script type="text/template">Slide A</script></section>' +
'<section >' +
'<section data-markdown><script type="text/template">Slide B</script></section>' +
'<section data-markdown><script type="text/template">Slide C</script></section>' +
'</section>'
);
});
});

it('should render speaker notes', () => {
render.parseSlides('Slide A\n\nNote: test', {}).then(actual => {
expect(actual.slides).toEqual('<section data-markdown><script type="text/template">Slide A\n\n<aside class="notes"><p>test</p>\n</aside></script></section>');
expect(actual.slides).toEqual(
'<section data-markdown><script type="text/template">Slide A\n\n<aside class="notes"><p>test</p>\n</aside></script></section>'
);
});
});

it('should parse YAML front matter', () => {
render.parseSlides('---\nseparator: <!--s-->\n---\nSlide A<!--s-->Slide B', {}).then(actual => {
expect(actual.slides).toEqual('' +
'<section data-markdown><script type="text/template">\nSlide A</script></section>' +
'<section data-markdown><script type="text/template">Slide B</script></section>');
expect(actual.slides).toEqual(
'' +
'<section data-markdown><script type="text/template">\nSlide A</script></section>' +
'<section data-markdown><script type="text/template">Slide B</script></section>'
);
});
});

it('should ignore comments (e.g. custom slide attributes)', () => {
render.parseSlides('Slide A\n\n---\n\n<!-- .slide: data-background="./image1.png" -->\nSlide B', {}).then(actual => {
expect(actual.slides).toEqual('' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">\n<!-- .slide: data-background="./image1.png" -->\nSlide B</script></section>');
});
render
.parseSlides('Slide A\n\n---\n\n<!-- .slide: data-background="./image1.png" -->\nSlide B', {})
.then(actual => {
expect(actual.slides).toEqual(
'' +
'<section data-markdown><script type="text/template">Slide A\n</script></section>' +
'<section data-markdown><script type="text/template">\n<!-- .slide: data-background="./image1.png" -->\nSlide B</script></section>'
);
});
});

it('should use preprocesser for markdown', () => {
render.parseSlides('# Slide A\n\ncontent\n\n# Slide B\n\ncontent', { preprocessor: 'test/preproc' }).then(actual => {
expect(actual.slides).toEqual('' +
'<section data-markdown><script type="text/template"># Slide A\n\ncontent\n\n</script></section>' +
'<section data-markdown><script type="text/template">\n# Slide B\n\ncontent</script></section>');
});
render
.parseSlides('# Slide A\n\ncontent\n\n# Slide B\n\ncontent', { preprocessor: 'test/preproc' })
.then(actual => {
expect(actual.slides).toEqual(
'' +
'<section data-markdown><script type="text/template"># Slide A\n\ncontent\n\n</script></section>' +
'<section data-markdown><script type="text/template">\n# Slide B\n\ncontent</script></section>'
);
});
});

});

0 comments on commit 00fb23f

Please sign in to comment.