Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing markdown2wiki script that reads markdown form stdin and …
…writes wiki to stdout
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env node | ||
// vim:ft=javascript | ||
|
||
var markdown2wiky = require('markdown-wiki').markdown2wiki | ||
, stdin = process.openStdin() | ||
|
||
stdin.setEncoding('utf8') | ||
stdin.on('data', function (data) { | ||
process.stdout.write((markdown2wiky(data))) | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var markdown2html = require('node-markdown').Markdown | ||
, html2wiki = require('wiky').toWiki | ||
|
||
function markdown2wiki(input) { | ||
return html2wiki(markdown2html(input)). | ||
// `x` -> <tt>x</tt> | ||
replace(/%([^%]*)%/g, '<tt>$1<\/tt>'). | ||
// <code>x</code> -> <source>x</source> | ||
replace(/<([\/]*)code>/g, '<$1source>'). | ||
// *x* -> <strong>x</strong> | ||
replace(/\*([^\*]*)\*/g, '<strong>$1</strong>'). | ||
// <li> -> * | ||
replace(/<li>/g, '* '). | ||
// <p>x</p> -> x | ||
replace(/<p[^>]*>/g, ''). | ||
// | ||
replace(/<\/source><\/tt>\]/g, '</source>'). | ||
replace(/\[<tt><source>/g, '<source>')//. | ||
//replace(/_([^_]*)_/g, '<emphasis>$1</emphasis>') | ||
} | ||
exports.markdown2wiki = markdown2wiki | ||
|
||
function wiki2markdown(input) { | ||
} | ||
exports.wiki2markdown = wiki2markdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
387c98e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parsing with rexeps makes for a sad panda - have you considered using github.com/evilstreak/markdown-js/ for the markdown part? It has an AST which might make the processing more robust.
387c98e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I'll take a look at that! I guess it's not / was not in npm registry back then