All Projects → remarkjs → remark-man

remarkjs / remark-man

Licence: MIT License
plugin to compile markdown to man pages

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to remark-man

remark-hint
Sprinkle hints/tips/warnings on your documents
Stars: ✭ 36 (-58.62%)
Mutual labels:  remark, remark-plugin
remark-behead
Remark plugin to increase or decrease markdown heading weight.
Stars: ✭ 14 (-83.91%)
Mutual labels:  remark, remark-plugin
cache
A cache for @remark-embedder
Stars: ✭ 12 (-86.21%)
Mutual labels:  remark, remark-plugin
remark-embed-images
plugin to embed local images as data URIs
Stars: ✭ 23 (-73.56%)
Mutual labels:  remark, remark-plugin
twoslash
You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible static code samples
Stars: ✭ 596 (+585.06%)
Mutual labels:  remark, remark-plugin
strip-markdown
plugin remove Markdown formatting
Stars: ✭ 84 (-3.45%)
Mutual labels:  remark, remark-plugin
remark-frontmatter
remark plugin to support frontmatter (YAML, TOML, and more)
Stars: ✭ 167 (+91.95%)
Mutual labels:  remark, remark-plugin
remark-directive
remark plugin to support directives
Stars: ✭ 137 (+57.47%)
Mutual labels:  remark, remark-plugin
remark-external-links
Legacy plugin to automatically add target and rel attributes to external links — please use `rehype-external-links` instead
Stars: ✭ 50 (-42.53%)
Mutual labels:  remark, remark-plugin
remark-autolink-headings
Legacy remark plugin to automatically add links to headings — please use `rehype-autolink-headings` instead
Stars: ✭ 63 (-27.59%)
Mutual labels:  remark, remark-plugin
remark-admonitions
Add admonitions support to Remarkable
Stars: ✭ 90 (+3.45%)
Mutual labels:  remark, remark-plugin
remark-slate-transformer
remark plugin to transform remark syntax tree (mdast) to Slate document tree, and vice versa. Made for WYSIWYG markdown editor.
Stars: ✭ 62 (-28.74%)
Mutual labels:  remark, remark-plugin
remark-highlight.js
Legacy plugin to highlight code blocks with highlight.js — please use `rehype-highlight` instead
Stars: ✭ 58 (-33.33%)
Mutual labels:  remark, remark-plugin
remark-license
plugin to generate a license section
Stars: ✭ 15 (-82.76%)
Mutual labels:  remark, remark-plugin
remark-bookmarks
plugin to manage links
Stars: ✭ 15 (-82.76%)
Mutual labels:  remark, remark-plugin
transformer-oembed
@remark-embedder transformer for oEmbed supported links
Stars: ✭ 25 (-71.26%)
Mutual labels:  remark, remark-plugin
remark-footnotes
Legacy plugin to add support for pandoc footnotes — please use `remark-gfm` instead
Stars: ✭ 38 (-56.32%)
Mutual labels:  remark, remark-plugin
RemarkPortable
Remark made simple and portable
Stars: ✭ 24 (-72.41%)
Mutual labels:  remark
awesome-remark
Curated list of awesome remark resources
Stars: ✭ 186 (+113.79%)
Mutual labels:  remark
nextjs-prism-markdown
Example using Prism / Markdown with Next.js including switching syntax highlighting themes.
Stars: ✭ 87 (+0%)
Mutual labels:  remark

remark-man

Build Coverage Downloads Size Sponsors Backers Chat

remark plugin to compile markdown to man pages.

Contents

What is this?

This package is a unified (remark) plugin that compiles markdown to roff/groff/troff (the format used for man pages).

unified is a project that transforms content with abstract syntax trees (ASTs). remark adds support for markdown to unified. mdast is the markdown AST that remark uses. This is a remark plugin that adds a compiler to compile mdast to a string.

When should I use this?

This plugin adds a compiler for remark, which means that it turns the final markdown (mdast) syntax tree into a string.

This plugin, combined with remark, is quite good at turning markdown into man pages. It has good unicode support, proper support for nested lists and block quotes, supports tables, and more.

Install

This package is ESM only. In Node.js (version 12.20+, 14.14+, or 16.0+), install with npm:

npm install remark-man

In Deno with Skypack:

import remarkMan from 'https://cdn.skypack.dev/remark-man@8?dts'

In browsers with Skypack:

<script type="module">
  import remarkMan from 'https://cdn.skypack.dev/remark-man@8?min'
</script>

Use

Say we have some markdown in example.md:

# ls(1) -- list directory contents

## SYNOPSIS

`ls` \[`-ABCFGHLOPRSTUW@abcdefghiklmnopqrstuwx1`] \[*file* *...*]

And our module 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'

main()

async function main() {
  const file = await unified()
    .use(remarkParse)
    .use(remarkMan)
    .process(await read('example.md'))

  file.extname = '.1'
  await write(file)
}

Now running node example.js creates a file example.1 that contains:

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

That’s not very readable but a man page viewer can solve that. Run man ./example.1 to view the rendered result.

API

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

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

Plugin to compile Markdown to man pages.

options

Configuration (optional).

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

Man 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.

Types

This package is fully typed with TypeScript. It exports an Options type, which specifies the interface of the accepted options.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js 12.20+, 14.14+, and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.

This plugin works with unified version 6+ and remark version 7+.

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].