Project

noratext

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
noratext is a simple (and rather stupid) lexer and parser generator for loosly markuped text.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 1.2.9
 Project Readme

noratext¶ ↑

DESCRIPTION:¶ ↑

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.

FEATURES¶ ↑

  • Noratext::Lexer/Noratext::Parser provides functionalty to parse markuped text.

PROBLEMS¶ ↑

  • 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.

SYNOPSIS¶ ↑

lexer : style A¶ ↑

# 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)

lexer : style B¶ ↑

# 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.