Index: hikidoc.rb =================================================================== --- hikidoc.rb (リビジョン 57220) +++ hikidoc.rb (リビジョン 57222) @@ -415,6 +415,7 @@ # BRACKET_LINK_RE = /\[\[.+?\]\]/ + RUBY_RE = /\(\(.+?\)\)/ URI_RE = /(?:https?|ftp|file|mailto|javascript):[A-Za-z0-9;\/?:@&=+$,\-_.!~*\'()#%]+/ WIKI_NAME_RE = /\b(?:[A-Z]+[a-z\d]+){2,}\b/ @@ -422,12 +423,14 @@ if @options[:use_wiki_name] if @options[:use_not_wiki_name] / (#{BRACKET_LINK_RE}) + | (#{RUBY_RE}) | (#{URI_RE}) | (#{MODIFIER_RE}) | (\^?#{WIKI_NAME_RE}) /xo else / (#{BRACKET_LINK_RE}) + | (#{RUBY_RE}) | (#{URI_RE}) | (#{MODIFIER_RE}) | (#{WIKI_NAME_RE}) @@ -435,6 +438,7 @@ end else / (#{BRACKET_LINK_RE}) + | (#{RUBY_RE}) | (#{URI_RE}) | (#{MODIFIER_RE}) /xo @@ -448,7 +452,7 @@ while m = re.match(str) str = m.post_match - link, uri, mod, wiki_name = m[1, 4] + link, ruby, uri, mod, wiki_name = m[1, 5] if wiki_name and wiki_name[0, 1] == "^" pending_str = m.pre_match + wiki_name[1..-1] + str next @@ -457,16 +461,18 @@ pre_str = "#{pending_str}#{m.pre_match}" pending_str = nil evaluate_plugin_block(pre_str, buf) - compile_inline_markup(buf, link, uri, mod, wiki_name) + compile_inline_markup(buf, link, ruby, uri, mod, wiki_name) end evaluate_plugin_block(pending_str || str, buf) buf end - def compile_inline_markup(buf, link, uri, mod, wiki_name) + def compile_inline_markup(buf, link, ruby, uri, mod, wiki_name) case when link buf << compile_bracket_link(link[2...-2]) + when ruby + buf << compile_ruby(ruby[2...-2]) when uri buf << compile_uri_autolink(uri) when mod @@ -502,6 +508,12 @@ image?(uri) and @options[:allow_bracket_inline_image] end + def compile_ruby(ruby) + rb, *rt = *ruby.split(")(", 3).map{|_| compile_inline(_) } + # rb, rtは rubyを含んではいけないけど compile_inlineは rubyを作りうる。とりあえず気にしない。 + @output.ruby(rb, *rt) + end + def compile_uri_autolink(uri) if image?(uri) @output.image_hyperlink(fix_uri(uri)) @@ -746,6 +758,28 @@ %Q(#{title}) end + def ruby(rb, *rt) + case rt.length + when 0 + $stderr.puts("possibly unintentional ruby markup.") + "((#{rb}))" + when 1 + ""+ + "#{rb}"+ + "("+ + "#{rt[0]}"+ + ")"+ + "" + else + ""+ + "#{rb}"+ + "("+ + rt.map{|_| "#{_}" }.join(" / ")+ + ")"+ + "" + end + end + def wiki_name(name) hyperlink(name, text(name)) end