• Stars
    star
    362
  • Rank 113,509 (Top 3 %)
  • Language
    Ruby
  • License
    Other
  • Created over 12 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📚 Converts markdown into UNIX manual pages

md2man - markdown to manpage

md2man is a Ruby library and a set of command-line programs that convert Markdown into UNIX manpages as well as HTML webpages using Redcarpet.

Features

  • Formats indented, tagged, and normal paragraphs: described in md2man(5).

  • Translates all HTML4 and XHTML1 entities into native roff equivalents.

  • Supports markdown extensions such as PHP Markdown Extra tables.

  • Usable from the command line as a filter in a UNIX command pipeline.

Examples

Try converting this example Markdown file into a UNIX manual page:

md2man-roff EXAMPLE.markdown > EXAMPLE.1

You can view the resulting UNIX manual page in your man(1) viewer:

man -l EXAMPLE.1

screenshot

Next, try converting the same example file into a HTML web page:

md2man-html EXAMPLE.markdown > EXAMPLE.html

You can view the resulting HTML manual page in your web browser:

firefox EXAMPLE.html

Installation

gem install md2man

Development

git clone https://github.com/sunaku/md2man
cd md2man
bundle install
bundle exec rake --tasks        # packaging tasks
bundle exec md2man-roff --help  # run it directly
bundle exec md2man-html --help  # run it directly

Usage

For roff output

At the command line

See md2man-roff(1) manual:

md2man-roff --help

Inside a Ruby script

Use the default renderer:

require 'md2man/roff/engine'

your_roff_output = Md2Man::Roff::ENGINE.render(your_markdown_input)

Build your own renderer:

require 'md2man/roff/engine'

engine = Redcarpet::Markdown.new(Md2Man::Roff::Engine, your_options_hash)
your_roff_output = engine.render(your_markdown_input)

Define your own renderer:

require 'md2man/roff/engine'

class YourManpageRenderer < Md2Man::Roff::Engine
  # ... your stuff here ...
end

engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
your_roff_output = engine.render(your_markdown_input)

Mix-in your own renderer:

require 'md2man/roff'

class YourManpageRenderer < Redcarpet::Render::Base
  include Md2Man::Roff
  # ... your stuff here ...
end

engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
your_roff_output = engine.render(your_markdown_input)

For HTML output

At the command line

See md2man-html(1) manual:

md2man-html --help

Inside a Ruby script

Use the default renderer:

require 'md2man/html/engine'

your_html_output = Md2Man::HTML::ENGINE.render(your_markdown_input)

Build your own renderer:

require 'md2man/html/engine'

engine = Redcarpet::Markdown.new(Md2Man::HTML::Engine, your_options_hash)
your_html_output = engine.render(your_markdown_input)

Define your own renderer:

require 'md2man/html/engine'

class YourManpageRenderer < Md2Man::HTML::Engine
  # ... your stuff here ...
end

engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
your_html_output = engine.render(your_markdown_input)

Mix-in your own renderer:

require 'md2man/html'

class YourManpageRenderer < Redcarpet::Render::Base
  include Md2Man::HTML
  # ... your stuff here ...
end

engine = Redcarpet::Markdown.new(YourManpageRenderer, your_options_hash)
your_html_output = engine.render(your_markdown_input)

Building manpages

At the command line

See md2man-rake(1) manual:

md2man-rake --help

Inside a Ruby script

Add this snippet to your gemspec file:

s.files += Dir['man/man?/*.?']         # UNIX manpages
s.files += Dir['man/**/*.{html,css}']  # HTML manpages
s.add_development_dependency 'md2man', '~> 5.0'

Add this line to your Rakefile:

require 'md2man/rakefile'

You now have a rake md2man task that builds manual pages from Markdown files (with ".markdown", ".mkd", or ".md" extension) inside man/man*/ directories. There are also sub-tasks to build manual pages individually as roff or HTML.

If you're using Bundler, this task also hooks into Bundler's gem packaging tasks and ensures that your manual pages are built for packaging into a gem:

bundle exec rake build
gem spec pkg/*.gem | fgrep man/

License

Like my work? 👍 Please spare a life today as thanks! 🐮🐷🐔🐟🙊✌️💞

Copyright 2011 Suraj N. Kurapati https://github.com/sunaku

Released under the ISC license. See the LICENSE file for details.

More Repositories

1

tamzen-font

💌 Bitmapped programming font, based on Tamsyn
Ruby
818
star
2

dasht

💁 Search API docs offline, in terminal or browser
Shell
803
star
3

vim-shortcut

💇 Discoverable & searchable shortcuts for (Neo)Vim
Vim Script
185
star
4

tork

💞 Tests your Ruby code, in parallel, as you change it
Ruby
181
star
5

vim-dasht

💁 (Neo)Vim plugin for dasht integration
Vim Script
131
star
6

home

🏡 My $HOME directory (dot files & bin scripts)
Shell
128
star
7

.vim

✌️ A modular (Neo)Vim configuration
Vim Script
112
star
8

vim-ruby-minitest

Vim highlighting & completion for MiniTest
Vim Script
107
star
9

glove80-keymaps

Glove80 keymap: "Glorious Engrammer"
HTML
100
star
10

vim-unbundle

🎁 Fast, filetype-lazy loader of Vim scripts & plugins
Vim Script
97
star
11

wmiirc

Ruby configuration for WMII window manager
Ruby
81
star
12

tmux-navigate

🥂 Seamless tmux/vim navigation (over SSH too!)
Shell
50
star
13

engrammer

Arno's Engram layout for programmers
Makefile
42
star
14

vim-hicterm

🌈 Highlights terminal color code numbers (0-255)
Vim Script
41
star
15

vim-modusline

🌈 Mode-specific statusline colors
Vim Script
39
star
16

binman

🤓 Creates manual pages from header comments
Ruby
36
star
17

wmii

My fork of the WMII window manager.
C
36
star
18

readably

📚 Static blogs: YAML + Slim → HTML5
Ruby
30
star
19

simple-ftp

My final project for CMPE-150 at UCSC during Spring 2004.
C
27
star
20

rumai

Ruby interface to 9P2000 protocol and WMII window manager
Ruby
21
star
21

bdf2fon

Convert X11 BDF fonts to Microsoft .FNT and .FON formats
C
15
star
22

ruby-vpi

Ruby interface to IEEE 1364-2005 Verilog VPI
Ruby
15
star
23

sunaku.github.io

🌟 My own little corner of the Web
HTML
10
star
24

.dwm

My dwm configuration with Ruby statusbar.
C
10
star
25

inochi

Infrastructure for Ruby projects
Ruby
10
star
26

ruby-coroutine-example

How to embed Ruby inside C coroutines.
C
9
star
27

ember

eRuby template processor
Ruby
8
star
28

sm4tik-font

BDF font of sm4tik's 8x8 XBM icons.
7
star
29

erbook

Write books, manuals, and documents in eRuby.
JavaScript
7
star
30

beakl15p

BEAKL-15p keyboard layout
7
star
31

kwalify

YAML schema validation for Ruby
7
star
32

swig-ruby-ffi

Ruby FFI language module for SWIG
C++
7
star
33

structy_record

🎩 Provides a Struct-like interface for Records
Elixir
6
star
34

detest

Assertion testing library for Ruby
Ruby
5
star
35

rassmalog

Static blogging with YAML and eRuby
Ruby
5
star
36

libixp

Mirror of 9P2000 library from WMII window manager.
C
5
star
37

babelfish

Ruby interface to Yahoo! BabelFish translation service.
Ruby
4
star
38

ofc2_to_png

Open Flash Chart 2 JSON to PNG converter
JavaScript
4
star
39

knights-tour

Knight's Tour algorithm in C, OpenGL, and Cg. This was my final project for CMPE-220 at UCSC during Winter 2007.
C
3
star
40

.dmenu

My dmenu configuration.
C
3
star
41

programming-elixir-issues

Sample project from the Programming Elixir book
Elixir
2
star
42

vim-ruby-shoulda-context

Vim highlighting & completion for shoulda-context.
Vim Script
2
star
43

firefox-tranquility

My fork of the Tranquility addon for Firefox
JavaScript
1
star
44

test-loop

MOVED TO sunaku/testr
1
star
45

kernel_hash

Adds a Kernel#Hash() method like Kernel#Array()
Ruby
1
star
46

redcarpet-manpage

renamed to md2man
1
star
47

test-unit-must

Selfish "must" assertions for Test::Unit
Ruby
1
star
48

ff-bash

For each File (GNU BASH)
Shell
1
star
49

opener

👐 A 33-line alternative to Ruby's launchy gem
Ruby
1
star
50

testr

MOVED TO sunaku/tork
1
star
51

onig-5.9.2

My patches to Oniguruma 5.9.2
C
1
star
52

test-unit-must.vim

Vim syntax highlighting for test-unit-must assertions
Vim Script
1
star
53

equal_rights_for_hash

Adds Kernel#Hash() and generic #to_h() methods.
Ruby
1
star