moinmoinにamazonのアソシエイトを貼り付けたくてマクロを作ってみた。といってもISBN.pyをいじっただけだけど。
html_code = """
<iframe src="http://rcm-jp.amazon.co.jp/e/cm?t=kaerutyuuihou-22
&o=9&p=48&l=st1&mode=%s&search=%s&fc1=000000<1=&
lc1=3366FF&bg1=FFFFFF&f=ifr" marginwidth="0"
marginheight="0" width="728" height="90" border="0"
frameborder="0" style="border:none;" scrolling="no"></iframe>
"""
def execute(macro, args):
f = macro.formatter
result = ''
if args:
args = [arg.strip() for arg in args.split(',')]
else:
args = []
if 1 > len(args):
result += f.strong(1) + \
f.text('Example: [[AMAZON("books-jp","perl")]]') + \
f.strong(0) + \
f.text(' - links to Amazon')
else:
result += html_code % tuple(args)
return result
で、
result += html_code % tuple(args)
の部分で最初リストを突っ込んでたせいでエラーが出てたのだけど理由がわからなかった。
っていうか差し込む場合に何でタプルでないといけないのかわからん。リストだ問題あんのかな?