Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

marked-plaintify

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

marked-plaintify

A marked extension to convert Markdown to Plaintext

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3K
increased by23.44%
Maintainers
1
Weekly downloads
 
Created
Source

marked-plaintify

A marked extension to convert Markdown to Plaintext.

Install

You can install marked-plaintify using npm or yarn:

npm i marked-plaintify
# or
yarn add marked-plaintify

Usage

Once you've installed this extension, you can use it in your marked configuration. Here's an example of how to configure it:

Say we have the following file example.md:

Click to view `example.md`:
# GitHub Flavored Markdown (GFM) Specifications Demo

This document showcases various features and specifications of GitHub Flavored Markdown (GFM).

## 1. Headings

### This is a third-level heading

#### This is a fourth-level heading

## 2. Emphasis

_This text will be italic_
_This will also be italic_

**This text will be bold**
**This will also be bold**

## 3. Lists

### Unordered List

- Item 1
- Item 2
  - Item 2a
  - Item 2b

### Ordered List

1. First item
2. Second item
3. Third item
   1. Indented item
   2. Indented item

## 4. Links

[Github](https://github.com) - Renders as a link to GitHub.

## 5. Images

![GitHub Logo](https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png)

## 6. Blockquotes

> This is a blockquote

## 7. Inline code

This is an `inline code` example.

## 8. Code blocks

```javascript
function greet(name) {
  console.log('Hello, ' + name + '!')
}

greet('World')
```

## 9. Strikethrough

~~This text is strikethrough.~~

## 10. Tables

| Column 1 | Column 2 | Column 3 |
| -------- | -------- | -------- |
| Cell 1   | Cell 2   | Cell 3   |
| Cell 4   | Cell 5   | Cell 6   |

## 11. Task lists

- [x] Task 1
- [x] Task 2
- [ ] Task 3

## 12. Mentioning users and issues

@username, #123

## 13. Emoji

:smile:, :rocket:, :octocat:

## 14. Automatic linking for URLs

https://www.google.com

## 15. Strikethrough

~~Strikethrough~~

## 16. Ignoring Markdown formatting

\*This will not be italic\*

## 17. Tables

| Markdown | Less      | Pretty     |
| -------- | --------- | ---------- |
| _Still_  | `renders` | **nicely** |
| 1        | 2         | 3          |

## 18. Fenced code blocks with language syntax highlighting

```python
def hello():
    print("Hello, World!")
```

## 19. Disabling line breaks in paragraphs

This is a paragraph that demonstrates how to
disable line breaks.

## 20. Automatic linking for URLs

www.example.com

And our module example.js looks as follows:

import { readFileSync } from 'node:fs'
import { Marked } from 'marked'
import markedPlaintify from 'marked-plaintify'

const plaintext = new Marked({ gfm: true })
  .use(markedPlaintify())
  .parse(readFileSync('example.md', 'utf8'))

console.log(plaintext)

Now, running node example.js yields:

GitHub Flavored Markdown (GFM) Specifications Demo

This document showcases various features and specifications of GitHub Flavored Markdown (GFM).

1. Headings

This is a third-level heading

This is a fourth-level heading

2. Emphasis

This text will be italic
This will also be italic

This text will be bold
This will also be bold

3. Lists

Unordered List


Item 1
Item 2
Item 2a
Item 2b

Ordered List


First item
Second item
Third item
Indented item
Indented item

4. Links

Github - Renders as a link to GitHub.

5. Images

GitHub Logo

6. Blockquotes

This is a blockquote

7. Inline code

This is an inline code example.

8. Code blocks

function greet(name) {
  console.log('Hello, ' + name + '!')
}

greet('World')

9. Strikethrough

This text is strikethrough.

10. Tables

Column 1: Cell 1
Column 2: Cell 2
Column 3: Cell 3

Column 1: Cell 4
Column 2: Cell 5
Column 3: Cell 6

11. Task lists


Task 1
Task 2
Task 3

12. Mentioning users and issues

@username, #123

13. Emoji

:smile:, :rocket:, :octocat:

14. Automatic linking for URLs

https://www.google.com

15. Strikethrough

Strikethrough

16. Ignoring Markdown formatting

This will not be italic

17. Tables

Markdown: Still
Less: renders
Pretty: nicely

Markdown: 1
Less: 2
Pretty: 3

18. Fenced code blocks with language syntax highlighting

def hello():
    print("Hello, World!")

19. Disabling line breaks in paragraphs

This is a paragraph that demonstrates how to
disable line breaks.

20. Automatic linking for URLs

www.example.com

API

markedPlaintify(options: Options): MarkedExtension

This function creates a marked extension to convert Markdown to plaintext.

  • options: Custom renderers for configuring the marked-plaintify extension. It's an object where keys represent renderer names and values are functions that take arguments and return plaintext strings or false.

See extensions list.

Contributing

We 💛  issues.

When committing, please conform to the semantic-release commit standards. Please install commitizen and the adapter globally, if you have not already.

npm i -g commitizen cz-conventional-changelog

Now you can use git cz or just cz instead of git commit when committing. You can also use git-cz, which is an alias for cz.

git add . && git cz

License

GitHub

A project by Stilearning © 2023-2024.

Keywords

FAQs

Package last updated on 22 Apr 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc