ASINの時[]を付けないとうまくいかなったのと、ISBN:NUM:image の書影表示(普通サイズだけ)が欲しかったので適当に改変。

href属性にASINを指定したときエラー。プラグインのオプションはスタイル内から参照できないからかな……? とりあえずアソシエイトIDもってないので削除しておく。

# ISBN & ASIN

# amazon.rb is required

class Hatena::Amazon

def initialize(str, tag_p, type="ISBN", image=false)

@str = str.gsub(/-/, "") #ISBN:4-10-111501-Xという形用

@tag_p = tag_p

@type = type

@image = image

end

def convert(mode)

if @tag_p

if @image

sprintf('<%%=isbn_image "%s", ""%%>', @str)

else

sprintf('<%%=isbn "%s", "%s:%s"%%>' , @str, @type, @str) # %=

end

else

sprintf('http://www.amazon.co.jp/exec/obidos/ASIN/%s/%s', @str, '') #アソシエイトIDをとりあえず削除。

end

end

end

class Hatena::TAG

when /\A(ISBN|ASIN):(.*)/

@elems.push Hatena::Amazon.new(Regexp.last_match[2], false, Regexp.last_match[1])

class Hatena::Inline

when /\A\[(ISBN|ASIN):(.*?)(:image(:(small|large))?)?\]/m, /\A(ISBN|ASIN):([-0-9A-Z]+)(:image(:(small|large))?)?/

@elems.push Hatena::Amazon.new(Regexp.last_match[2], true, Regexp.last_match[1], Regexp.last_match[3])

when /\A\[((?:https?|ftp|mailto).*?)\]/m#, /\A(#{URI.regexp})/o

@elems.push Hatena::URI.new(Regexp.last_match[1])

URI.regexp は割と何でもマッチするのではずしてみる……

めんどくさいので time.rbrequire してins|deldatetime 要素を自動挿入。

*t* を変換してるところで適当に置き換え。

class Hatena::Sectioninitialize

@src.gsub!(/<(ins|del)>/, %Q|<\\1 datetime="#{Time::now.xmlschema}">|)

はてなのキーワードAPIはジャンル指定できないか……

ソースも tDiary とかはてなと同じようなソースを吐くよう(改行少なめ、そのかわりネギが多め)に。

<div class="section"> をつけ足し。

name=""id="" に(XHTML化)

  1. トップ
  2. tDiary
  3. はてなスタイル ASIN: ISBN:
▲ この日のエントリ