Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

simple-pandoc

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-pandoc

A thin and simple pandoc wrapper function

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
119
85.94%
Maintainers
1
Weekly downloads
 
Created
Source

simple-pandoc Build Status

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 = require('simple-pandoc');

Initialize a converter

pandoc(from, to, ...opts)

  • from: String a format specified in the pandoc documentation
  • to: String a format specified in the pandoc documentation
  • opts: ...String options specified in the pandoc documentation
  • return: Function a converter function

Example:

const htmlToMarkdown = pandoc('html', 'markdown', '--no-highlight', '--key=value', ...);

Convert with a Promise API

converter(content)

  • content: String|Buffer content in the from format to be converted
  • return: Promise<Buffer> promised content in the to format

Example:

const htmlToMarkdown = pandoc('html', 'markdown');

htmlToMarkdown(fs.readFileSync('index.html'))
  .then(md => {
    console.log(md.toString());
  });

Even better with async/await:

const htmlToMarkdown = pandoc('html', 'markdown');

async function convert() {
  const html = fs.readFileSync('index.html');
  const md = await htmlToMarkdown(html);
  console.log(md.toString());
}

convert();

Convert with streams

converter.stream(readStream)

  • readStream: Readable a stream conveying content in the from format

  • return: Readable a stream conveying converted content in the to format

Example:

const htmlToMarkdown = pandoc('html', 'markdown');

const inputStream = fs.createReadStream('index.html');
const outputStream = fs.createWriteStream('index.md');
htmlToMarkdown.stream(inputStream).pipe(outputStream);

License

MIT © Jun

Keywords

pandoc

FAQs

Package last updated on 29 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts