Module: Doublesing

Defined in:
lib/doublesing.rb,
lib/doublesing/parser.rb,
lib/doublesing/version.rb,
lib/doublesing/builtins.rb,
lib/doublesing/transformer.rb,
lib/doublesing/builtins/bold.rb,
lib/doublesing/builtins/link.rb,
lib/doublesing/builtins/header.rb,
lib/doublesing/builtins/italic.rb

Overview

The Doublesing module is the main interface for interacting with Doublesing

Defined Under Namespace

Modules: Builtins Classes: Parser, Transformer

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.assign(name, klass) ⇒ Object

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



24
25
26
# File 'lib/doublesing.rb', line 24

def self.assign(name, klass)
  @@handlers[name] = klass
end

.parse(str) ⇒ Object

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.



13
14
15
16
17
18
# 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!Object

Load default block handlers YOU MUST CALL THIS BEFORE ANYTHING ELSE



30
31
32
33
# File 'lib/doublesing.rb', line 30

def self.setup!
  @@handlers = {}
  @@handlers.merge! Builtins.handlers
end