Module XOXO
In: xoxo.rb

XOXO provides a Ruby API similar to Marshal and YAML (though more specific) to load and dump XOXO, an simple, open outline format written in standard XHTML and suitable for embedding in (X)HTML, Atom, RSS, and arbitrary XML.

Methods

dump   load  

Constants

VERSION = "0.1"   xoxo.rb version number

Public Class methods

Return a XOXO string corresponding to the Ruby object struct, translated to the following rules:

  • Arrays become ordered lists <ol>.
  • Hashes become definition lists <dl>, keys are stringified with to_s.
  • Everything else becomes stringified with to_s and wrapped in appropriate list elements (<li> or <dt>/<dd>).

Additionally, you can pass these options on the options hash:

:html_wrap => true:Wrap the XOXO with a basic XHTML 1.0 Transitional header.
:css => css:Reference css as stylesheet for the wrapped XOXO document.

[Source]

    # File xoxo.rb, line 45
45:   def self.dump(struct, options={})
46:     struct = [struct]  unless struct.kind_of? Array
47: 
48:     if options[:html_wrap]
49:       result = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\nhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head profile=\"\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n".strip
50:       if options[:css]
51:         result << %Q[<style type="text/css" >@import "#{options[:css]}";</style>]
52:       end
53: 
54:       result << "</head><body>" << make_xoxo(struct, 'xoxo') << "</body></html>"
55:     else
56:       result = make_xoxo(struct, 'xoxo')
57:     end
58: 
59:     result
60:   end

Load and return a XOXO structure from the String, IO or StringIO or xoxo.

[Source]

    # File xoxo.rb, line 22
22:   def self.load(xoxo)
23:     structs = Parser.new(xoxo).parse.structs
24:     while structs.kind_of?(Array) && structs.size == 1
25:       structs = structs.first
26:     end
27:     structs
28:   end

[Validate]