remark-man
    TypeScript icon, indicating that this package has built-in type declarations

    8.0.0 • Public • Published

    remark-man

    Build Coverage Downloads Size Sponsors Backers Chat

    remark plugin to compile Markdown to man pages.

    • [x] Great unicode support
    • [x] Name, section, and description detection
    • [x] Nested block quotes and lists
    • [x] Tables
    • [x] and much more

    Note!

    This plugin is ready for the new parser in remark (micromark, see remarkjs/remark#536). No change is needed: it works exactly the same now as it did before!

    Install

    This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

    npm:

    npm install remark-man

    Use

    Say we have the following file, example.md:

    # ls(1) -- list directory contents
    
    ## SYNOPSIS
    
    `ls` \[`-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1`] \[*file* *...*]

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

    import {read, write} from 'to-vfile'
    import {unified} from 'unified'
    import remarkParse from 'remark-parse'
    import remarkMan from 'remark-man'
    
    read('example.md')
      .then((file) => unified().use(remarkParse).use(remarkMan).process(file))
      .then((file) => {
        file.extname = '.1'
        return write(file)
      })

    Now, running node example and cat example.1 yields:

    .TH "LS" "1" "June 2019" "" ""
    .SH "NAME"
    \fBls\fR - list directory contents
    .SH "SYNOPSIS"
    .P
    \fBls\fR \[lB]\fB-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1\fR\[rB] \[lB]\fIfile\fR \fI...\fR\[rB]

    Now, that in my opinion isn’t very readable, but that’s roff/groff/troff. 😉

    To properly view that man page, use something like this: man ./example.1.

    API

    This package exports no identifiers. The default export is remarkMan.

    unified().use(remarkMan[, options])

    Plugin to compile Markdown to man pages.

    options
    options.name

    Title of the page (string, optional). Is inferred from the main heading (# hello-world(7) sets name to 'hello-world') or from the file’s name (hello-world.1.md sets name to 'hello-world').

    options.section

    Section of page (number or string, optional). Is inferred from the main heading (# hello-world(7) sets section to 7) or from the file’s name (hello-world.1.md sets section to 1).

    options.description

    Description of page (string, optional). Is inferred from the main heading (# hello-world(7) -- Two common words sets description to 'Two common words').

    options.date

    Date of page (number, string, or Date, optional). Given to new Date(date) as date, so when null or undefined, defaults to the current date. Dates are centered in the footer line of the displayed page.

    options.version

    Version of page (string, optional). Versions are positioned at the left of the footer line of the displayed page (or at the left on even pages and at the right on odd pages if double-sided printing is active).

    options.manual

    Manual of page (string, optional). Manuals are centered in the header line of the displayed page.

    Security

    Use of remark-man does not involve rehype (hast) or user content so there are no openings for cross-site scripting (XSS) attacks.

    Related

    Contribute

    See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help.

    This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

    License

    MIT © Titus Wormer

    Install

    npm i remark-man

    DownloadsWeekly Downloads

    38

    Version

    8.0.0

    License

    MIT

    Unpacked Size

    31.5 kB

    Total Files

    15

    Last publish

    Collaborators

    • johno
    • wooorm