From 78d1a7046e70c5f9394634537f86afa16aa5d128 Mon Sep 17 00:00:00 2001 From: Ricardo Tomasi Date: Tue, 14 May 2013 04:04:47 -0300 Subject: [PATCH] Add markdown parser --- adapters/compilers.coffee | 9 +++++++++ test/compilers/markdown.spec.coffee | 27 +++++++++++++++++++++++++++ test/sources/simple.md | 6 ++++++ 3 files changed, 42 insertions(+) create mode 100644 test/compilers/markdown.spec.coffee create mode 100644 test/sources/simple.md diff --git a/adapters/compilers.coffee b/adapters/compilers.coffee index 448d161..2c661b9 100644 --- a/adapters/compilers.coffee +++ b/adapters/compilers.coffee @@ -48,6 +48,15 @@ module.exports = new Adapter throw err if err cb css + md: (file, cb) -> + marked = require 'marked' + + marked.setOptions Adapter.getOptions(this) + + file.read (code) -> + compiled = marked code + cb compiled + hbs: (file, cb) -> handlebars = require 'handlebars' diff --git a/test/compilers/markdown.spec.coffee b/test/compilers/markdown.spec.coffee new file mode 100644 index 0000000..7ab8916 --- /dev/null +++ b/test/compilers/markdown.spec.coffee @@ -0,0 +1,27 @@ +flour = require '../../flour' +should = require 'should' + +flour.silent() + +describe 'Markdown compiler', -> + + input_file = "#{dir.sources}/simple.md" + output_file = "#{dir.temp}/simple.html" + + it 'should compile markdown and return the output', (done) -> + flour.compile input_file, (output) -> + output.should.include """ +

H1

+

Hello, paragraph.

+

H2

+ """ + done() + + it 'should compile markdown to a file', (done) -> + flour.compile input_file, output_file, -> + readFile(output_file).should.include """ +

H1

+

Hello, paragraph.

+

H2

+ """ + done() diff --git a/test/sources/simple.md b/test/sources/simple.md new file mode 100644 index 0000000..53f1b6b --- /dev/null +++ b/test/sources/simple.md @@ -0,0 +1,6 @@ +H1 +=============== + +Hello, paragraph. + +## H2 \ No newline at end of file