Sha256: 6c51f6f31d8a1171fdfae5a61e9ac6ca3c0b93a0db951cf5fe7813f5a0145eb7

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

Literati
========

Render literate Haskell into HTML using Ruby and magic.  But mostly Ruby.

    Literati.render("Markdown here\n\n> your literate Haskell here\n\nMore Markdown.")
    # =>  <p>Markdown here</p>

          <pre><code class="haskell">your literate Haskell here
          </code></pre>

          <p>More Markdown.</p>

Simple and straightforward!  

By default, we render using Markdown.  If you want to use another markup language or Markdown renderer, then you can use the extra magical extended API.  The only requirement is that the class takes the content as the sole argument for the initializer and exposes a `to_html` method.  An example `RedCarpet` wrapper would look like this:

    # A simple class to wrap passing the right arguments to RedCarpet.
    class RedCarpetRenderer
      # Create a new compatibility instance.
      #
      # content - The Markdown content to render.
      def initialize(content)
        require 'redcarpet/compat'
        @content = content
      end

      # Render the Markdown content to HTML.  We use GFM-esque options here.
      #
      # Returns an HTML string.
      def to_html
        Markdown.new(@content, :fenced_code, :safelink, :autolink).to_html
      end
    end

You can easily use that as a base for other wrappers.  If you wanted to use, for example, a `reStructuredText` wrapper of some sort with `literati`, you'd do something like this:

    renderer = Literati::Renderer.new("content", RSTRenderer)
    renderer.to_html

The second, optional argument to the `Renderer` class's initializer is the class (i.e., *not* an instance) that you'll use to build the HTML.  If you leave that option off, it'll default to our `RedCarpetRenderer` class.

Lastly, you can use the simple binscript we included:

    literati file.lhs

That'll pipe the HTML to `stdout` so you can direct it wherever.

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
literati-0.0.4 README.md
literati-0.0.3 README.md