SunokoDocをHikiのstyleに設定する方法
スタイルの新規作成
Hikiに style/sunokodoc を新規作成し以下のファイルを置く。
html_formatter.rb parser.rb sunokodoc.rb
html_formatter.rb の中身
html_formatter.rb は default の中身を拝借。以下を書き換える。
class HTMLFormatter_sunokodoc < HikiFormatter
parser.rb の中身
parser.rb は default を拝借。以下とする。
# $Id: parser.rb,v 1.22 2005/12/28 22:42:55 fdiary Exp $
# Copyright (C) 2002-2003 TAKEUCHI Hitoshi <hitoshi@namaraii.com>
require 'style/default/hikidoc'
require 'style/sunokodoc/sunokodoc' #追加
module Hiki
class Parser_sunokodoc #変更
class << self
def heading( str, level = 1 )
'!' * level + str
end
def link( link_str, str = nil )
str ? "[[#{str}|#{link_str}]]" : "[[#{link_str}]]"
end
def blockquote( str )
str.split(/\n/).collect{|s| %Q|""#{s}\n|}.join
end
end
def initialize( conf )
end
def parse( s, top_level = 2 )
s = SunokoDoc.new( s ).to_wiki #追加
HikiDoc.new( s, :level => top_level ).to_html
end
end
end
sunokodoc.rb の作成
sunokodoc.rb はSunokoDocとする。ファイル名が小文字となっているので注意。
編集支援プラグインの修正
plugin/02help.rb の修正 による方法
編集支援プラグインが必要な場合、 02help.rb を修正する。別に必要ない、という場合はどうでも良い。
def help_enabled? #(@conf.style == "default" || @conf.style == "math") && !@conf.mobile_agent? (@conf.style == "default" || @conf.style == "math" || @conf.style == "sunokodoc") && !@conf.mobile_agent? end
sunokodoc_help.rb を使用する方法
plugin ディレクトリに、添付 sunokodoc_help.rb をコピーする。 02help.rbがあっても問題ない。同じメソッド名を使っているので置き換わるだけ。
<文字支援>に<SunokoDoc>ボタンが追加されている。このボタンを押すことで
<SunokoDoc> </SunokoDoc>
が編集エリアに挿入される。
ファイルはsunokodoc_help.rbより落としてください。
Keyword(s):[Hiki] [SunokoDoc]
References: