module Doublesing

The Doublesing module is the main interface for interacting with Doublesing

Constants

VERSION

Public Class Methods

assign(name, klass) click to toggle source

Assign a handler for a custom block class. name: Name the block should respond to klass: class the block should be generated from Note:

# File lib/doublesing.rb, line 24
def self.assign(name, klass)
  @@handlers[name] = klass
end
parse(str) click to toggle source

This method takes a string of source in the Doublesing language, and returns the resulting HTML It will sanitize any HTML fragments out of the source first, for safety’s sake.

# File lib/doublesing.rb, line 13
def self.parse(str)
  sanitized = Sanitize.fragment(str)
  tree = Parser.new.parse(sanitized)
  res = Transformer.new.apply(tree)
  res.join("")
end
setup!() click to toggle source

Load default block handlers YOU MUST CALL THIS BEFORE ANYTHING ELSE

# File lib/doublesing.rb, line 30
def self.setup!
  @@handlers = {}
  @@handlers.merge! Builtins.handlers
end

Protected Class Methods

process(id, args) click to toggle source

Take the id of a block and its arguments and process it, returning html.

# File lib/doublesing.rb, line 38
def self.process(id, args)
  if handler = @@handlers[id.to_s]
    handler.new(args).to_s
  else
    ""
  end
end