Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
 
 
 
 
 
 
 
 
 
 

README.md

invert-markdown

inverts markdown code, converting fenced code into the body and markdown into comments

To install, run npm install invert-markdown.

This contains a script. For usage run ./node_modules/.bin/invert-markdown --help. You can try it on this file with ./node_modules/.bin/invert-markdown README.md. The output will be written to stdout.

var invertMarkdown = require('./');
var assert = require('assert');

function testConvertToJavascript() {
  var input = "# Hello\n\n``` javascript\nconsole.log('Hello World')\n```\n\nThis is an example\n";
  var expected = "// # Hello\n\nconsole.log('Hello World')\n\n// This is an example\n";
  var output = invertMarkdown(input);
  assert.strictEqual(output, expected);
}

function testConvertToMarkdown() {
  var input = "// # Hello\n\nconsole.log('Hello World')\n\n// This is an example\n";
  var expected = "# Hello\n\n``` javascript\nconsole.log('Hello World')\n```\n\nThis is an example\n";
  var output = invertMarkdown(input);
  assert.strictEqual(output, expected);
}

testConvertToJavaScript();
testConvertToMarkdown();

console.log('it worked!');

LICENSE

MIT

About

inverts javascript code in a markdown file

Resources

Packages

No packages published