0.0
No commit activity in last 3 years
No release in over 3 years
Standardized markup parsers to use a single format: an object. Instantiate a specific markup class with text to output formated Html. Allows for easy code block highlighting using a Proc; defaults to Uv (ruby Ultraviolet)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 0
>= 2.0.0b
>= 0
 Project Readme

= Markup Parser

Creating my own rails wiki application forced me to do some research on markup parsers. I ended up using a ton of Github solutions (and code) but in the end found their 'markup' gem to be a little cumbersome and behind some of the new advances (specifically Redcarpet 2)

So I created my own little library.

Goals

  • Make the library simple (class oriented, easy to read, small)
  • Standardize the parser usage
  • Allow leveraging the features and hooks of parsers

Usage

List the available markup parsers:

MarkupParser.format_parsers #=> { 'markdown' => MarkupParser::Markdown, 'rdoc' => MarkupParser::Rdoc }

Parse some text to Html:

MarkupParser::Markdown.new("body").to_html #=> "<p>body<p>"

Note that the MarkupParser::Markdown is the parser for Markdown, and can be reused by just creating a new instance.

Styling Code Blocks

Another goal was to simplify code block styling. MarkupParser doesn't stylize the code, but instead lets you easily accomplish it with your own code styler:

markup = MarkupParser::Html.new("<pre lang='ruby'>Class</pre>")
markup.stylize_code_blocks { |code, lang|
  Albino.colorize(code, lang)
}
markup.to_html #=> "<pre class='highlight'><span class='class'>Class</span></pre>"

Or:

MarkupParser::Html.new("<pre lang='ruby'>Class</pre>").stylize_code_blocks { |code, lang|
  Albino.colorize(code, lang)
}.to_html #=> "<pre class='highlight'><span class='class'>Class</span></pre>"

For each code block recognized by the markup language, stylize_code_blocks accepts a block with parameters: code, lang for you to use.

Adding Markup Parsers

Ask me (Todo)