postmodern / kramdown-man

Allows you to write man pages in pure markdown.
MIT License
85 stars 4 forks source link

Support more than Kramdown. #5

Closed envygeeks closed 11 years ago

envygeeks commented 11 years ago

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.

postmodern commented 11 years ago

You probably want to use md2man instead, which relies on Redcarpet. However, the project is maintained at a much slower pace. Also, not all GitHub flavoured markdown can be translated to roff.

The impetus for this project was that:

  1. Redcarpet is a C extension, and JRuby >= 1.7.0 doesn't support C extensions. This makes testing the full stack on TravisCI difficult.
  2. Kramdown::Document provides a superior DOM of the Markdown document.
  3. Kramdown also provides a Converter API.
envygeeks commented 11 years ago

Sure we could use MD2Man but somebody suggested that we use your project to support you so I was trying to expand your project to support our needs... that is if you would have wanted me to do the actual hard work of making it modular to do that and can't be translated to Roff is a subjective statement that itself implies that you cannot make a ruleset to what happens in those situations that is sane. As for the others:

  1. You can fix that with Matrix exclusions... we use it on DataMapper.
  2. Needs more explanation because Kramdown provides no DOM.
    1. It's also signifincantly easier to support Redcarpet see: This Page
  3. The convertor API doesn't allow us to remove a product that is slower than other extensions.

I was never implying rid of Kramdown, I was implying support multiple markdown translators, this provides much better coverage than others and would put you at the top considering people can choose what they like.

postmodern commented 11 years ago
  1. I ended up grouping md2man / redcarpet gems with platforms :mri, :rbx. Unfortunately, this prevents JRuby users from building the full gem, since the man pages are included in gemspec.files and are generated by Kramdown::Manpage::Tasks.
  2. Kramdown is as fast as your Ruby implementation. ;) That said, the developer has put a lot of work into making it faster than the other pure-Ruby markdown processors.
  3. I didn't know Redcarpet supports generated man pages out of the box! Makes me wonder why I spent all that time struggling with md2man. Now that I know this, I suggest that you should just use Redcarpet::Render::ManPage.
postmodern commented 11 years ago

I guess by DOM, I mean AST.

require 'kramdown'

doc = Kramdown::Document.new("* foo\n* bar\n\n> baz")
doc.root.children
# => [<kd:ul nil [<kd:li nil [<kd:p nil {:transparent=>true} [<kd:text "foo" nil>]>]>, <kd:li nil [<kd:p nil {:transparent=>true} [<kd:text "bar" nil>]>]>]>, <kd:blank "\n" nil>, <kd:blockquote nil [<kd:p nil [<kd:text "baz" nil>]>]>]

All nodes in the AST are Kramdown::Elements. An element can have:

Using the above metadata, it's extremely simple to write a Converter class, which simply traverses the AST, convert elements into output Strings. This is why it took approximately three hours to write a kramdown -> roff Converter, using md2man and ronn as reference implementations.

envygeeks commented 11 years ago

To address the first:

  1. Make the task generic and provide a wrapper API inside of each type of modular parser. It's not hard.
  2. Implies that Kramdown uses the most optimized Ruby code, it does not. I know this by fact.
    1. To further this subjective assessment if it did then it would be a pure C extension.
    2. If you are "working on making something faster" it does not fall down to "as fast as your ruby"
  3. Anything to resist us supporting your project? Much irony to the situations where you complain to about this?

To address the second:

You seem to keep trying to imply that Kramdown has a far superior API and whatever you are showing above does not prove it somehow has a better API because I could point out how easy it is to build a rendering engine for Redcarpet by way of simply sending you here: https://github.com/vmg/redcarpet/blob/master/lib/redcarpet/render_man.rb#L5 and pointing out it requires nothing more than inheriting a base class, building a few methods and then passing that renderer into Redcarpet. As a matter of fact, most modular developers would probably agree that Redcarpet has the superior API and Kramdown simply has a wider reaching API.

postmodern commented 11 years ago

I've already looked at Redcarp::Render::ManPage, and it only supports rendering a limited subset of markdown and roff, even less than what md2man supports.

The primary goal of this project is to use Kramdown to render markdown -> roff (thus the name kramdown-manpage), so that I can replace md2man/redcarpet with a JRuby friendly markdown->roff converter, and finally return to getting Ronin passing on TravisCI I do not want to be stuck supporting multiple markdown processors, as it is out of the scope for this project. You have already stated that you are tied to and prefer Redcarpet, so you should use Redcarpet::Render::ManPage. If you really want to support all markdown parsers, you should consider writing a gem that abstracts away Ronn, md2man, kramdown-manpage, etc.