lib/luobo.rb in luobo-0.1.0 vs lib/luobo.rb in luobo-0.1.2

- old
+ new

@@ -70,10 +70,16 @@ else self.do__missing(token) end end + # convert inline processor + def conv_inline p, a, ln, line + # indent_level, processor_name, line_code, block_open + convert Token.new(ln, line, 0, p, a, false) + end + # processor converters and dump callbacks def do_setup; "" end # call before all tokens def do_cleanup; "" end # call after all tokens def do__raw token @@ -145,9 +151,16 @@ # add a new line to the existing token if it requires block codes # or write the last token out before a new token # this function invokes after a loop expansion or if the line # is not in any examples and loop templates. def process_line ln, line + # convert inline processor + while /\#\#(?<p_>[A-Z][_A-Z0-9]*)(:\s*(?<a_>.+))?\#\#/ =~ line + rst = conv_inline(p_, a_, ln, line) + raise "do not use '##.*##' inside your inline processor converting result" if rst =~ /\#\#[A-Z][_A-Z0-9]*(:\s*.+)?\#\#/ + line.sub!(/\#\#[A-Z][_A-Z0-9]*(:\s*.+)?\#\#/, rst) + end + # create a token, with processor name token = self.tokenize(ln, line) # based on the the token indent level, close token stack if any self.close_stack token.indent_level