Skip to content
This repository has been archived by the owner on Jan 20, 2020. It is now read-only.
/ Noratext Public archive

noratext is a simple (and rather stupid) lexer and parser generator for loosly markuped text.

License

Notifications You must be signed in to change notification settings

skoji/Noratext

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

noratext is a simple (and rather stupid) lexer and parser generator for loosly markuped text.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages