Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/manovotny/remark-excerpt
Remark transformer for extracting an excerpt.
https://github.com/manovotny/remark-excerpt
excerpt markdown preview remark remark-plugin teaser
Last synced: 19 days ago
JSON representation
Remark transformer for extracting an excerpt.
- Host: GitHub
- URL: https://github.com/manovotny/remark-excerpt
- Owner: manovotny
- License: mit
- Created: 2019-02-14T04:19:49.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2023-10-23T19:46:37.000Z (about 1 year ago)
- Last Synced: 2024-11-29T05:43:10.915Z (about 1 month ago)
- Topics: excerpt, markdown, preview, remark, remark-plugin, teaser
- Language: JavaScript
- Homepage:
- Size: 1020 KB
- Stars: 8
- Watchers: 2
- Forks: 3
- Open Issues: 5
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license
Awesome Lists containing this project
README
# remark-excerpt
> [Remark](https://remark.js.org/) transformer for extracting an excerpt.
This is a [remark](https://remark.js.org/) plugin for transformer for extracting an excerpt, similar to [WordPress's excerpt functionality](https://kinsta.com/knowledgebase/wordpress-excerpt/).
## Installation
### NPM
```
$ npm i remark-excerpt
```### Yarn
```
$ yarn add remark-excerpt
```## Usage
Say we have the following file, `example.md`:
```
# TitleParagraph 1.
Paragraph 2.
Paragraph 3.
Paragraph 4.
```And our script, `example.js`, looks as follows:
```js
const remark = require('remark');
const excerpt = require('remark-excerpt');
const vfile = require('to-vfile');(async () => {
const file = await vfile.read('example.md');
const result = await remark().use(excerpt).process(file);console.log(result.toString());
})();
```Now, running `node example` yields:
```
# TitleParagraph 1.
Paragraph 2.
```You can try this yourself by downloading or cloning the project, installing dependencies, and running `yarn example`.
## API
### `remark().use(excerpt[, options])`
Returns markdown content specified before the excerpt comment.
#### Options
##### `identifier`
Type: `String`
Default: `excerpt`, `more`, `preview`, or `teaser`Specifies the excerpt comment identifier to look for.
## License
MIT © [Michael Novotny](https://manovotny.com)