New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markup_parser

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markup_parser

  • 0.0.9
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= 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)

FAQs

Package last updated on 11 Oct 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc