Compile markdown to man pages with remark. Great unicode support; name, section, and description detection; nested block quotes and lists; tables; and much more.
npm:
npm install remark-man
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
.
Compile markdown to a man page.
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'
.
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
.
string
, optional β Description of page.
Is inferred from the main heading: # hello-world(7) -- Two common words
sets
description
to 'Two common words'
.
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.
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).
string
, optional β Manual of page. Manuals are centred in the header line of
the displayed page.
Set to true
(default: false
) to prefer the first when duplicate definitions
are found. The default behaviour is to prefer the last duplicate definition.
remark-react
β Compile to Reactremark-vdom
β Compile to VDOMremark-html
β Compile to HTMLremark-rehype
β Properly transform to HTML
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.
MIT Β© Titus Wormer