joehua87 / remark-unlink

Remove all links, references and definitions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

remark-unlink Build Status Coverage Status Chat

Remove all links, references, and definitions with remark.

Original motivation was to process Markdown documents in a way that would make it easier to read as a plain text. On an ebook reader or a piece of paper the links are useless and look ugly.

Installation

npm:

npm install remark-unlink

Usage

Say we have the following file, example.md. Imagine section titles and URLs a bit longer though.

## TOC

- [section 1](#section-1)
- [section 2](#section-2)

## section 1

Section [content][1] may include some [links](https://domain.name/path).

[1]: https://domain.name/path

## section 2

![some images are here also](https://gif.com/1.gif)

More content.

And our script, example.js, looks as follows:

var vfile = require('to-vfile')
var remark = require('remark')
var unlink = require('remark-unlink')

remark()
  .use(unlink)
  .process(vfile.readSync('example.md'), function(err, file) {
    if (err) throw err
    console.log(String(file))
  })

Now, running node example yields:

## TOC

-   section 1
-   section 2

## section 1

Section content may include some links.

## section 2

More content.

API

remark().use(unlink)

Transform the tree to remove links, images, references, and definitions.

Contribute

See contributing.md in remarkjs/remark for ways to get started.

This organisation has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.

License

MIT © Eugene Sharygin

About

Remove all links, references and definitions

License:MIT License


Languages

Language:JavaScript 100.0%