parse/unparseは却下

せっかく書いたけど却下みたい。ぐは。行き詰まり感。


processメソッドの定義が難解になりすぎる。サッパリになってしまう。ダメすぎる。



代替案として、syntax_convertを定義する、というのはどうか。

inline["link"].module_eval {
  def process
    if @syntax.include?("splitter")
      text, to = @text.split(@syntax["splitter"],2)
    elsif text.include?("\to")
      text, to = @text.split("\to",2)
    else
      text, to = @text
    end
    %[<a href="#{CGI.escapeHTML(to)}">#{CGI.escapeHTML(text)}</a>]
  end

  def self.syntax_convert(from_syntax, to_syntax, text)
    if from_syntax.include?("splitter") && text.include?(from_syntax["splitter"])
      if to_syntax.include?("splitter")
        return text.split(from_syntax["splitter"],2).join(to_syntax["splitter"])
      else
        return text.split(from_syntax["splitter"],2).join("\\to")
      end
    else
      return text
    end
  end
}