root/docs/cho45/20080622-rubykaigi-subsession-net-irc/t.rb

Revision 14427, 0.9 kB (checked in by cho45, 7 months ago)

RubyKaigi?

  • Property svn:executable set to *
Line 
1#!/usr/bin/env ruby
2
3
4
5require "rubygems"
6require "hparser"
7
8require "pp"
9
10require 'hparser/block/pair'
11require 'hparser/block/collectable'
12
13class HParser::Block::Comment < HParser::Parser::Pair
14        include HParser::Parser::Collectable
15
16        def self.parse(scanner, inlines)
17                content = get(scanner, '><!--', '--><')
18                if content then
19                        self.new content
20                end
21        end
22
23        def self.<=>(o)
24                -1
25        end
26
27        def to_html
28                ""
29        end
30end
31
32parsed =  HParser::Parser.new.parse(File.read(__FILE__)[/__END__\n([\s\S]+)/, 1])
33
34pp parsed
35
36puts parsed.map{|i| i.to_html }
37#
38#sections = parsed.inject([[]]) do |r,element|
39#       element.instance_variable_set(:@level, element.level + 1) if element.kind_of?(HParser::Block::Head)
40#       if element.kind_of?(HParser::Block::Head) && element.level == 2
41#               r << [element]
42#       else
43#               r.last << element
44#       end
45#       r
46#end
47
48__END__
49
50* Agenda
51
52+ Introducing to net-irc
53+ About the DSL (or something DSL-ish)
54+ Applications using net-irc
55
56><!--
57aaa
58--><
59
60* Fo
61
62aaaa
Note: See TracBrowser for help on using the browser.