Markdown to reStructuredText
Convert Markdown to reStructuredText.
Installation
$ npm install markdown-to-restructuredtext
Installation prerequisites:
Usage
var md2rst = ;
md2rst( [dest,] src[, opts], clbk )
Asynchronously converts a Markdown file to reStructuredText.
;{if errorthrow error;console;}
The destination
and source
file paths may be either absolute or relative. If relative, a file path is resolved relative to the current working directory.
var inFile = '/path/to/my/file.md';var outFile = './../output.rst';process;;{if errorthrow error;console;}
If not provided a destination
file path, the function
returns a reStructuredText string
.
;{if errorthrow error;console;}
The function
accepts the following options:
By default, the function
assumes standard Markdown. To convert from a different Markdown flavor, set the flavor
option.
var opts ='flavor': 'github' // GFM;;{if errorthrow error;console;}
md2rst.sync( [dest,] src[, opts] )
Synchronously converts a Markdown file to reStructuredText.
// Write to an output file:md2rst;// Return a reStructuredText string:var rst = md2rst;// returns <string>
The function
accepts the same options
as md2rst()
.
md2rst.fromString( [dest,] str[, opts], clbk )
Asynchronously converts a Markdown string
to reStructuredText.
var readFile = sync;var data = ;md2rst;{if errorthrow error;console;}
If not provided a destination
file path, the function
returns a reStructuredText string
.
md2rst;{if errorthrow error;console;}
The function
accepts the same options
as md2rst()
.
md2rst.fromStringSync( [dest,] str[, opts] )
Synchronously converts a Markdown string
to reStructuredText.
var readFile = sync;var data = ;// Write to an output file:md2rst;// Return a reStructuredText string:var rst = md2rst;// returns <string>
The function
accepts the same options
as md2rst()
.
md2rst.fromBuffer( [dest,] buffer[, opts], clbk )
Asynchronously converts a Markdown buffer
to reStructuredText.
var readFile = sync;var data = ;md2rst;{if errorthrow error;console;}
If not provided a destination
file path, the function
returns a reStructuredText string
.
md2rst;{if errorthrow error;console;}
The function
accepts the same options
as md2rst()
.
md2rst.fromBufferSync( [dest,] buffer[, opts] )
Synchronously converts a Markdown buffer
to reStructuredText.
var readFile = sync;var data = ;// Write to an output file:md2rst;// Return a reStructuredText string:var rst = md2rst;// returns <string>
The function
accepts the same options
as md2rst()
.
Examples
var path = ;var md2rst = ;var inFile = path;var outFile = path;var opts ='flavor': 'github';;{if errorthrow error;console;};{if errorthrow error;console;console;}
To run the example code from the top-level application directory,
$ DEBUG=* node ./examples/file_async/index.js
CLI
Installation
To use the module as a general utility, install the module globally
$ npm install -g markdown-to-restructuredtext
Usage
Usage: md2rst [options] inFileOptions:-h, --help Print this message.-V, --version Print the package version.--flavor flavor Markdown flavor. Default: (none).-o, --output file Output file path.
Notes
- If not provided an
output
file path, the generated reStructuredText is written tostdout
.
Examples
$ DEBUG=* md2rst --flavor=github -o ./README.rst ./README.md
For local installations, modify the command to point to the local installation directory; e.g.,
$ DEBUG=* ./node_modules/.bin/md2rst --flavor=github -o ./README.rst ./README.md
Or, if you have cloned this repository and run npm install
, modify the command to point to the executable; e.g.,
$ DEBUG=* node ./bin/cli --flavor=github -o ./README.rst ./README.md
Tests
Unit
This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:
$ make test
All new feature development should have corresponding unit tests to validate correct functionality.
Test Coverage
This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
$ make test-cov
Istanbul creates a ./reports/coverage
directory. To access an HTML version of the report,
$ make view-cov
License
Copyright
Copyright © 2016. Athan Reines.