Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

brightly

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brightly

  • 0.1.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= Brightly

Easily add code a syntax highlighting system to Markdown to make your site's markdown a little more useful.

== Point?

There is a wonderful gem that lets you syntax highlight based on TextMate sytle's (Ultraviolet). There's only one problem. The dependencies required to use it don't exist on Heroku. Aww no Heroku love? No. Just wrap you Markdown requests into a simple REST call to this little service and your set.

== Server Setup

You'll need Onigurma to use ultraviolet which is used do do the highlighting in Brightly (hence the whole reason for the service).

Website: http://www.geocities.jp/kosako3/oniguruma/

OS X Installation (from source):

curl -O http://www.geocities.jp/kosako3/oniguruma/archive/onig-5.9.1.tar.gz tar xvf onig-5.9.1.tar.gz cd onig-5.9.1 ./configure make sudo make install

OS X Installation (from ports):

sudo port install oniguruma

Ubuntu Installation:

sudo aptitude install libonig-dev sudo gem install oniguruma

Brightly:

sudo gem install brightly --source=http://gemcutter.org

For development you can easily run brightly via the command line:

brightly

Will start a Sinatra server going.

To get things running with a webserver (passenger + apache, etc) using rack set your config up like:

config.ru: begin require 'brightly' rescue require 'rubygems' require 'brightly' end run Brightly::Provider::Base

You can easily set up a brightly app for passenger with:

brightly -p brightly

Then just add the outputted config to your apache config.

== Client Usage

The simplest way to use brighten in a rails application is to create a helper method that can make the requests. You could likely create an ActiveResource model for this, but the data is hardly representative of a model, so a simple method call makes more sense.

A simple method can be added to your model which makes the call to Brightly:

def brighten(markdown, theme = 'blackboard') Net::HTTP.post_form(URI.parse("http://127.0.0.1:4567/brighten"), {:markdown => markdown, :theme => theme}).body end

Remember that you likely don't want to do this every hit to a page, markdown processing is done with RDiscount so it's fast, but code highlighting and markdown processing and the service call all adds up. Store the result, get better performance.

Cheers!

== And in you Markdown

Here's some ruby: def candy puts "is sweet!" end

== Things of Interest

Making this I stumbled upon an interesting Rack Middleware which also does syntax highlighting. If you don't need to make the call to a service, it might be of use you you. Check it out: http://coderack.org/users/wbzyl/entries/19-rackcodehighlighter

== Copyright

Copyright (c) 2009 Adam Elliot. See LICENSE for details.

FAQs

Package last updated on 23 Nov 2009

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