class Qwik::EmodePreProcessor
Constants
- HMARK
Public Class Methods
add_line(next_line, ar, line)
click to toggle source
# File vendor/qwik/lib/qwik/parser-emode.rb, line 48 def self.add_line(next_line, ar, line) case line when /\A(=+)\z/ # only = return 'h2' when /\A(------+)/ # only - return 'h3' when /\A([→・])(.*)\z/ ar << '-'+$2 return next_line when /\A([●■])(.*)\z/ ar << '***'+$2 return next_line end ignore_chars = [?\s, ?-, ?*, ?>, ?|, ?,, ?{, ?}] if ignore_chars.include?(line[0]) || line.empty? ar << line return next_line end ar << line+"{{br}}" return next_line end
emode?(str)
click to toggle source
# File vendor/qwik/lib/qwik/parser-emode.rb, line 11 def self.emode?(str) /\A============================================================/ =~ str end
preprocess(str)
click to toggle source
# File vendor/qwik/lib/qwik/parser-emode.rb, line 20 def self.preprocess(str) next_line = nil num = 0 ar = [] str.each {|line| line.chomp! if next_line if next_line == 'h2' num += 1 end if /\A([●■])(.*)\z/ =~ line ar << HMARK[next_line] + $2 else if next_line == 'h2' ar << '*' + num.to_s else ar << "====" end next_line = add_line(next_line, ar, line) end next_line = nil else next_line = add_line(next_line, ar, line) end } return ar.join("\n") end