JavaScript
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.editorconfig
.gitignore
.npmrc
.prettierignore
.travis.yml
LICENSE
index.js
package.json
readme.md

readme.md

remark-man Build Status Coverage Status Chat

Compile markdown to man pages with remark. Great unicode support; name, section, and description detection; nested block quotes and lists; tables; and much more.

Installation

npm:

npm install remark-man

Usage

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:

var vfile = require('to-vfile')
var unified = require('unified')
var markdown = require('remark-parse')
var man = require('remark-man')

unified()
  .use(markdown)
  .use(man)
  .process(vfile.readSync('example.md'), function(err, file) {
    if (err) throw err
    file.extname = '.1'
    vfile.writeSync(file)
  })

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

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

Now, that looks horrible, but that’s how roff/groff/troff are 😉.

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

remark.use(man[, options])

Compile markdown to a man page.

Options
name

string, optional — Title of the page. 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'.

section

number or string, optional — Section of page. 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.

description

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

date

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

version

string, optional — Version of page. 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).

manual

string, optional — Manual of page. Manuals are centred in the header line of the displayed page.

commonmark

Set to true (default: false) to prefer the first when duplicate definitions are found. The default behaviour is to prefer the last duplicate definition.

Related

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 © Titus Wormer