Edgewall Software

MacroBazaar: Center.py

File Center.py, 666 bytes (added by ksa@…, 6 years ago)

add Center macro

Line 
1"""
2Macro for a centering environment
3
4{{{
5[[Center(begin)]]
6}}}
7starts the centered environment
8
9{{{
10[[Center(end)]]
11}}}
12ends the centered environment
13
14"""
15from StringIO import StringIO
16
17def execute(hdf, args, env):
18    buf = StringIO()
19    if args:
20        if args == 'begin':
21            buf.write("<center>")
22        elif args == 'end':
23            buf.write("</center>")
24        else:
25            buf.write("<p style='font-weight:bold; color:red;'>[[Center()]] macro unknown keyword %s</p>\n" % (args))
26
27    else:
28        buf.write("<p style='font-weight:bold; color:red;'>[[Center()]] macro requires keyword 'begin' or 'end'</p>\n")
29
30    return buf.getvalue()