1.0.1 • Published 6 months ago

uniorg-extract-keywords v1.0.1

Weekly downloads
-
License
GPL-3.0-or-later
Repository
github
Last release
6 months ago

uniorg-extract-keywords

uniorg plugin to extract Org-mode keywords from the document and store them in vfile.data.

Install

npm install --save uniorg-extract-keywords

Use

If we have the following example.org file:

#+TITLE: Post title
#+AUTHOR: Your Name

other org-mode

and

import { unified } from 'unified';
import toVFile from 'to-vfile';
import uniorgParse from 'uniorg-parse';
import { extractKeywords } from 'uniorg-extract-keywords';
import uniorg2rehype from 'uniorg-rehype';
import html from 'rehype-stringify';

unified()
  .use(uniorgParse)
  .use(extractKeywords)
  .use(uniorg2rehype)
  .use(html)
  .process(toVFile.readSync('./example.org'), function (err, file) {
    console.log(file.toString());
    console.log(file.data);
  });

will output

<p>other org-mode
</p>

{ title: 'Post title', author: 'Your Name' }

Note: you should use to-vfile@6. to-vfile@7 is currently incompatible with unified@9. See #12 for more details.

Options

name

Type: string?

Default: undefined

Specify a key to store keywords under. For example, { name: 'keywords' } will store all keyword values as { data: { keywords: { ... } } }. By default, all keywords are merged into the data object.

Example:

unified()
  .use(uniorgParse)
  .use(extractKeywords, { name: 'keywords' })
  .use(uniorg2rehype)
  .use(html)
  .process('#+TITLE: Example', function (err, file) {
    console.log(file.data);
  });

will output

{ keywords: { title: 'Example' } }

preserveCase

Type: boolean

Default: false

Whether to preserve case of the keywords. By default, all keywords are converted to lowercase.

Example:

unified()
  .use(uniorgParse)
  .use(extractKeywords, { preserveCase: true })
  .use(uniorg2rehype)
  .use(html)
  .process('#+TITLE: Example', function (err, file) {
    console.log(file.data);
  });

will output

{ TITLE: 'Example' }

License

GNU General Public License v3.0 or later

1.0.1

6 months ago

1.0.0

1 year ago

0.5.6

1 year ago

0.5.3

2 years ago

0.5.2

2 years ago

0.5.0

2 years ago

0.5.1

2 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.21

3 years ago

0.1.20

3 years ago