diff --git a/bristlecode_nodes.rb b/bristlecode_nodes.rb index 11fdfd1..c662cb4 100644 --- a/bristlecode_nodes.rb +++ b/bristlecode_nodes.rb @@ -15,7 +15,9 @@ module Bristlecode end def inspect(indent="") - "#{indent}TextNode: #{text_value}" + s = "#{indent}TextNode:\n" + text_value.each_line{|line| s += "#{indent} #{line}"} + s end def to_html @@ -23,13 +25,30 @@ module Bristlecode end end + ############################## + # bold + ############################## + + class BoldNode < Treetop::Runtime::SyntaxNode + end + class BoldOpenNode < Treetop::Runtime::SyntaxNode end class BoldCloseNode < Treetop::Runtime::SyntaxNode end - class BoldNode < Treetop::Runtime::SyntaxNode + ############################## + # italic + ############################## + + class ItalicNode < Treetop::Runtime::SyntaxNode + end + + class ItalicOpenNode < Treetop::Runtime::SyntaxNode + end + + class ItalicCloseNode < Treetop::Runtime::SyntaxNode end class TagNode < Treetop::Runtime::SyntaxNode diff --git a/bristlecode_parser.treetop b/bristlecode_parser.treetop index 1dcb10b..b7fe881 100644 --- a/bristlecode_parser.treetop +++ b/bristlecode_parser.treetop @@ -1,6 +1,6 @@ grammar Bristlecode rule root - (tag / text)+ + (tag / text)* end rule text @@ -8,7 +8,7 @@ grammar Bristlecode end rule tag - (bold) + bold / italic end ############################## @@ -29,4 +29,23 @@ grammar Bristlecode rule bold_close '[/b]' / '[/B]' end + + ############################## + # italic + ############################## + + rule italic + italic_open + ((!italic_close .)+ ) + italic_close + + end + + rule italic_open + '[i]' / '[I]' + end + + rule italic_close + '[/i]' / '[/I]' + end end