noratext is a simple (and rather stupid) lexer and parser generator for loosly marked-up text. current version supports xml-like, but not valid-xml (like old HTML) markup.
will support wiki-style markup soon.
-
Noratext::Lexer/Noratext::Parser provides functionalty to parse markuped text.
-
only provides xml-style tags support.
-
need to write duplicated rules for Lexar and Parser. e.g., need to define same tag for Lexar and Parser.
# define lexer :my_ml。Noratext::Lexer.define :my_ml, :xml_style do
symbols :chapter, :section, :strong, :center, :right, :font-size, :blockquote, :code, :change_paragraph without_close :change_paragraph match_pattern :change_paragraph, 'p' # tag is <p> , not <change-paragraph> rawtext_till_close :code # add attribute parser add_parser :font-size do |s|
/size=“(.?)”/ =~ s { :size => $1 }
end
end
# use the lexer Noratext::Lexer.parse(io)
# define symbols Noratext::Lexer.define :my_ml, :xml_style do
symbol :chapter symbol :section symbol :strong symbol :center symbol :right symbol :blockquote symbol :font-size add_parser do |s| /size="(.?)"/ =~ s { :size => $1 } end end symbol :code do rawtext_till_close end symbol :change_paragraph do without_close
match_pattern ‘p’
end
end
# use the lexer Noratext::Lexer.parse(io)
Copyright © 2010 KOJIMA Satoshi. See LICENSE for details.