Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit cffed1274d0ac9b194497718a3bd33082f1c9c81 @tj tj committed Apr 20, 2010
Showing with 162 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +3 −0 .gitmodules
  3. +5 −0 History.md
  4. +51 −0 Readme.md
  5. +7 −0 seed.yml
  6. +50 −0 src/markdown.cc
  7. +7 −0 test.js
  8. +8 −0 test/test.html
  9. +7 −0 test/test.md
  10. +21 −0 wscript
@@ -0,0 +1,3 @@
+src/*.o
+build
+.lock-wscript
@@ -0,0 +1,3 @@
+[submodule "deps/discount"]
+ path = deps/discount
+ url = git://github.com/Orc/discount.git
@@ -0,0 +1,5 @@
+
+0.0.1 / 2010-04-07
+==================
+
+ * Initial release
@@ -0,0 +1,51 @@
+
+# Markdown.js
+
+ node bindings for the C "discount" markdown implementation by David Parsons.
+ Currently only simply parsing is supported, flags hopefully coming soon.
+
+## Installation
+
+You will need to install [Discount](http://github.com/Orc/discount) from source, or using
+a package management tool such as [homebrew](http://github.com/mxcl/homebrew), or apt-get.
+
+When using the [Kiwi](http://github.com/visionmedia/kiwi) package manager for node run:
+
+ $ kiwi install markdown
+
+Otherwise you will need to update the git submodules and run:
+
+ $ make
+
+In order to generate _build/markdown.node_.
+
+## Usage
+
+ var md = require('markdown')
+ md.parse('markdown is *awesome*')
+ // => "<p>markdown is <em>awesome</em></p>"
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2009 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,7 @@
+---
+ name: Markdown
+ description: C markdown implementation by David Parsons
+ tags: markdown md parser native
+ build: node-waf configure build
+ lib: build/default
+ version: 0.0.1
@@ -0,0 +1,50 @@
+
+//
+// markdown.cc
+//
+// (c) 2009 TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
+//
+
+#include <v8.h>
+#include <node.h>
+
+extern "C" {
+ #include <mkdio.h>
+}
+
+using namespace v8;
+using namespace node;
+
+/*
+ * Parse the given string of markdown.
+ */
+
+static Handle<Value>
+Parse(const Arguments& args) {
+ HandleScope scope;
+ char *buf;
+ int len;
+ if (args.Length() < 1 || !args[0]->IsString())
+ return ThrowException(Exception::TypeError(String::New("String expected")));
+ MMIOT *doc;
+ String::Utf8Value in(args[0]);
+ if ((doc = mkd_string(*in, in.length(), 0)) == 0)
+ return ThrowException(Exception::Error(String::New("Failed to parse markdown")));
+ if (mkd_compile(doc, 0))
+ len = mkd_document(doc, &buf);
+ Handle<String> md = String::New(buf);
+ mkd_cleanup(doc);
+ return md;
+}
+
+/*
+ * Initialize.
+ */
+
+extern "C" void
+init (Handle<Object> target)
+{
+ HandleScope scope;
+ target->Set(String::New("version"), String::New("0.0.1"));
+ NODE_SET_METHOD(target, "parse", Parse);
+}
@@ -0,0 +1,7 @@
+
+var assert = require('assert'),
+ fs = require('fs'),
+ markdown = require('./build/markdown')
+
+assert.ok(markdown.version.match(/^\d+\.\d+\.\d+$/), 'version is improperly formatted')
+assert.equal(fs.readFileSync('test/test.html'), markdown.parse(fs.readFileSync('test/test.md')))
@@ -0,0 +1,8 @@
+<h1>Welcome</h1>
+
+<h2>Articles</h2>
+
+<ul>
+<li>a</li>
+<li>b</li>
+</ul>
@@ -0,0 +1,7 @@
+
+# Welcome
+
+## Articles
+
+* a
+* b
@@ -0,0 +1,21 @@
+srcdir = '.'
+blddir = 'build'
+VERSION = '0.0.1'
+
+def set_options(opt):
+ opt.tool_options('compiler_cxx')
+
+def configure(conf):
+ conf.check_tool('compiler_cxx')
+ conf.check_tool('node_addon')
+ conf.check(
+ lib = 'markdown',
+ libpath = ['/usr/lib', '/usr/local/lib', '/opt/local/lib'],
+ uselib_store = 'DISCOUNT'
+ )
+
+def build(bld):
+ obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
+ obj.target = 'markdown'
+ obj.source = 'src/markdown.cc'
+ obj.uselib = 'DISCOUNT'

0 comments on commit cffed12

Please sign in to comment.