Project

doublesing

0.0
No commit activity in last 3 years
No release in over 3 years
An extensible markup language
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Doublesing Logo

Build Status Test Coverage Code Climate

Doublesing is a wiki markup language based on TeX. It's very simple and extremely flexible. You can register your own tags (including over-riding builtin ones) to suit your needs, effectively allowing a custom dialect to be built with just ruby objects.

Installation

Add this line to your application's Gemfile:

gem 'doublesing'

And then execute:

$ bundle

Or install it yourself as:

$ gem install doublesing

Usage

Doublesing is a TeX-like language designed to be used for online markup. It takes the relatively simple form of:

\BLOCK_ID[ARGUMENT][ARGUMENT][ARGUMENT]

Here, maybe a use case will help:

\bold[This text becomes bold!]

Becomes:

<b>This text becomes bold!</b>

You can have blocks that take multiple arguments:

\header[1][This is a header]
<h1>This is a header</h1>

Parsing this is easy:

Doublesing.setup! # Must call once, probably in an initializer
Doublesing.parse(str) #=> Processed HTML

Where it gets interesting is the fact that you can register your own block types. A common use case of this might be to add site-specific functionality. Let's say you're making a website about pictures of famous dogs. You probably want your user to be able to reference dogs pretty quickly. Well, with Doublesing, you can do something like:

class DogFinder
  def initialize(args)
    @dog_name = args.first
    @body = args[1]
  end

  def find_dog
    dog = Dog.where(name: @dog_name).pluck(:id).first
    "/dogs/#{dog.id}"
  end

  def to_s
    "<a href=\"#{find_dog}\">#{@body.to_s}</a>"
  end
end

Then, register it:

Doublesing.register("dog", DogFinder)

Now, assuming you're using Doublesing to parse comments, a user can say:

\dog[Rowlf][My favorite musical dog!]

To easily get a link to the page on the piano player of the Muppets. Pretty neat, huh?

Run rake specification to generate a .pdf with the full specification of built-in blocks.

There aren't that many right now, but you're free to submit a pull request with one! Note: You gotta have PDFLatex installed for that to work.

Contributing

  1. Fork it ( https://github.com/AnthonySuper/Doublesing/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request