A thin and simple pandoc wrapper function
Introduction
simple-pandoc
provides probably the thinest and simplest Node.js binding for
pandoc. It just wraps the pandoc
command into JavaScript APIs.
It focuses on a very simple use case, and may not provide complicated functionalities. If they are needed, please check out other libraries on npm.
Install
simple-pandoc
doesn't provide pandoc
itself. Please ensure that pandoc
is installed and executable. To install pandoc, please refer to the
Installing section in the pandoc
documentation.
To install simple-pandoc
, use npm.
$ npm install simple-pandoc
API
const pandoc = ;
Initialize a converter
pandoc(from, to, ...opts)
from
:String
a format specified in the pandoc documentationto
:String
a format specified in the pandoc documentationopts
:...String
options specified in the pandoc documentation- return:
Function
a converter function
Example:
const htmlToMarkdown = ;
Convert with a Promise API
converter(content)
content
:String|Buffer
content in thefrom
format to be converted- return:
Promise<Buffer>
promised content in theto
format
Example:
const htmlToMarkdown = ; ;
Even better with async/await:
const htmlToMarkdown = ; { const html = fs; const md = await ; console;} ;
Convert with streams
converter.stream(readStream)
-
readStream
:Readable
a stream conveying content in thefrom
format -
return:
Readable
a stream conveying converted content in theto
format
Example:
const htmlToMarkdown = ; const inputStream = fs;const outputStream = fs;htmlToMarkdown;
License
MIT © Jun