Giter VIP home page Giter VIP logo

kramdown-man's Introduction

kramdown-man

CI Code Climate Gem Version

Description

Allows you to write man pages for commands in pure Markdown and convert them to roff using Kramdown.

Features

  • Converts markdown to roff:
    • Supports codespans, emphasis, and strong fonts.
    • Supports normal and tagged paragraphs.
    • Supports codeblocks and blockquotes.
    • Supports bullet, numbered, and definition lists.
    • Supports multi-paragraph list items and blockquotes.
    • Supports converting [foo-bar](foo-bar.1.md) and [bash](man:bash(1)) links into SEE ALSO man page references.
  • Provides a handy kramdown-man command for converting or previewing markdown man pages.
  • Provides a rake task for converting man/*.md into man pages.
  • Uses the pure-Ruby Kramdown markdown parser.
  • Supports Ruby 3.x, JRuby, and TruffleRuby.

Synopsis

usage: kramdown-man [options] MARKDOWN_FILE
    -o, --output FILE                Write the man page output to the file
    -V, --version                    Print the version
    -h, --help                       Print the help output

Examples:
    kramdown-man -o man/myprogram.1 man/myprogram.1.md
    kramdown-man man/myprogram.1.md

Render a man page from markdown:

kramdown-man -o man/myprogram.1 man/myprogram.1.md

Preview the rendered man page:

kramdown-man man/myprogram.1.md

Examples

Render a man page from a markdown file:

require 'kramdown/man'

doc = Kramdown::Document.new(File.read('man/kramdown-man.1.md'))
File.write('man/kramdown-man.1',doc.to_man)

system 'man', 'man/kramdown-man.1'

Rake Task

Define a man and file tasks which render all *.md files within the man/ directory:

require 'kramdown/man/task'
Kramdown::Man::Task.new

Then you can generate man pages for all *.md in the man/ directory:

$ rake man

Syntax

Code

`code`

code

Emphasis

*emphasis*

emphasis

Strong

**strong**

strong

Paragraph

Normal paragraph.

Normal paragraph.

Usage String

`command` [`--foo`] **FILE**

command [--foo] FILE

Argument Definitions

*ARG*
: Description here.

ARG : Description here.

Option Definitions

`-o`, `--option` *VALUE*
: Description here.

-o, --option VALUE : Description here.

Links

[website](http://example.com/)

website

Man Pages

Link to other man pages in a project:

[kramdown-man](kramdown-man.1.md)

kramdown-man

Link to other system man page:

[bash](man:bash(1))

bash

Note: only works on firefox on Linux.

Email Addresses

Email [email protected]

Lists

* one
* two
* three
  • one
  • two
  • three

Numbered Lists

1. one
2. two
3. three
  1. one
  2. two
  3. three

Definition Lists

ex·am·ple
: a thing characteristic of its kind or illustrating a general rule.

: a person or thing regarded in terms of their fitness to be imitated or the likelihood of their being imitated.

ex·am·ple : a thing characteristic of its kind or illustrating a general rule.

: a person or thing regarded in terms of their fitness to be imitated or the likelihood of their being imitated.

Blockquotes

> Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
>
> --Antoine de Saint-Exupéry

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.

--Antoine de Saint-Exupéry

Code Blocks

    #include <stdio.h>

    int main()
    {
        printf("hello world\n");
        return 0;
    }
#include <stdio.h>

int main()
{
    printf("hello world\n");
    return 0;
}

Code Fences

```
puts "hello world"
```
puts "hello world"

Requirements

Install

gem install kramdown-man

Alternatives

Copyright

Copyright (c) 2013-2023 Hal Brodigan

See {file:LICENSE.txt} for details.

kramdown-man's People

Contributors

justinhorner avatar postmodern avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

kramdown-man's Issues

Bold text at block beginning results in hanging left indentation

Bold text at the beginning of a text block creates a hanging left indentation (.HP) in roff output:

**shards** requires the presence of a `shard.yml` file in the project
folder (working directory). This file describes the project and lists
dependencies that are required to build it.
.HP
\fBshards\fP requires the presence of a \fBshard.yml\fR file in the project
folder (working directory)\. This file describes the project and lists
dependencies that are required to build it\.

That seems unexpected to me. And .HP is deprecated.

Support converting typographic_sym Elements

Support converting typographic_sym elements. Kramdown will automatically parse certain sequences of characters into HTML entities.

doc = Kramdown::Document.new("-- Mr. Smith")
doc.root.children[0].children
# => [<kd:typographic_sym :ndash nil>, <kd:text " Mr. Smith" nil>]

Allow us to disable the "generated by" message.

It would be nice to disable the generated by. For sure we will love to give credit to your project on our site but having it on every manpage generated for our docs can just get in the way. I understand the the anger that might be caused by that logic but if we all had to comply with that we would all have Generated by "Insert guy who originally created the first modern processor as we know it".

Replace `convert_p` logic with real support for markdown definition lists

Instead of trying to identify paragraphs that start with a code, em, or strong element and who's first line isn't indented but the following lines are indented, kramdown-man should just use normal markdown definition lists. This will entail adding convert_dt and convert_dd methods, which outputs a .TP modifier, followed by the term and the definition body.

Current Syntax

`-o`, `--option`, *VALUE*
  Description of the option goes here.
  
...

New Syntax

`-o`, `--option` **VALUE**
: Description of the option goes here.

...

Desired Roff Output

.TP
\fB-o\fR, \fB--option\fR \fBALUE\fP
Description of the option goes here.

man link with dot is broken

A man link containing a dot seems to be broken:

See [shard.yml](man:shard.yml(5)) for more information.
See
.BR shard for more
information\.

Support more than Kramdown.

We don't use Kramdown on our sites, we prefer Redcarpet & Github-Markdown through html-pipeline.
If you need help tell me where I can start and I'll be happy to help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.