Permalink
Browse files

Add my markdown parser

  • Loading branch information...
1 parent 3cc2ac1 commit 108788fb871fceceedcb4ffaa4c536bed2da11b2 @naoty committed Mar 30, 2014
Showing with 53 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +30 −0 markdown
  3. +22 −0 package.json
View
@@ -0,0 +1 @@
+node_modules/
View
@@ -0,0 +1,30 @@
+#!/usr/bin/env node
+
+var marked = require("marked");
+var renderer = new marked.Renderer();
+
+renderer.code = function (code, header) {
+ var metadata = header.split(":");
+ var language = metadata[0];
+ var filename = metadata[1];
+
+ var text = "";
+ text += '<div class="code-block">';
+ if (filename) {
+ text += '<div class="code-header"><span>';
+ text += filename;
+ text += "<span></div>";
+ }
+ text += '<div class="code-body"><pre>';
+ text += code;
+ text += "</pre></div></div>";
+ return text;
+};
+
+process.stdin.resume();
+process.stdin.setEncoding("utf8");
+
+process.stdin.on("data", function (chunk) {
+ console.log(marked(chunk, {renderer: renderer}));
+});
+
View
@@ -0,0 +1,22 @@
+{
+ "name": "bin",
+ "version": "0.1.0",
+ "description": "",
+ "main": "index.js",
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/naoty/bin"
+ },
+ "author": "Naoto Kaneko <naoty.k@gmail.com>",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/naoty/bin/issues"
+ },
+ "homepage": "https://github.com/naoty/bin",
+ "dependencies": {
+ "marked": "~0.3.2"
+ }
+}

0 comments on commit 108788f

Please sign in to comment.