All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 Licensed under MIT License
5 * (c) 2009, Uli Schlachter
10 local format = string.format
11 local setmetatable = setmetatable
13 -- Lain markup util submodule
15 local markup = { fg = {}, bg = {} }
18 function markup.bold(text) return format("<b>%s</b>", text) end
19 function markup.italic(text) return format("<i>%s</i>", text) end
20 function markup.strike(text) return format("<s>%s</s>", text) end
21 function markup.underline(text) return format("<u>%s</u>", text) end
22 function markup.monospace(text) return format("<tt>%s</tt>", text) end
23 function markup.big(text) return format("<big>%s</big>", text) end
24 function markup.small(text) return format("<small>%s</small>", text) end
27 function markup.font(font, text)
28 return format("<span font='%s'>%s</span>", font, text)
32 function markup.fg.color(color, text)
33 return format("<span foreground='%s'>%s</span>", fg, bg, text)
37 function markup.bg.color(color, text)
38 return format("<span background='%s'>%s</span>", fg, bg, text)
41 -- Set foreground and background
42 function markup.color(fg, bg, text)
43 return format("<span foreground='%s' background='%s'>%s</span>", fg, bg, text)
46 -- Set font and foreground
47 function markup.fontfg(font, fg, text)
48 return format("<span font='%s' foreground='%s'>%s</span>", font, fg, text)
51 -- Set font and background
52 function markup.fontbg(font, bg, text)
53 return format("<span font='%s' background='%s'>%s</span>", font, bg, text)
56 -- Set font, foreground and background
57 function markup.fontcolor(font, fg, bg, text)
58 return format("<span font='%s' foreground='%s' background='%s'>%s</span>", font, fg, bg, text)
61 -- link markup.{fg,bg}(...) calls to markup.{fg,bg}.color(...)
62 setmetatable(markup.fg, { __call = function(_, ...) return markup.fg.color(...) end })
63 setmetatable(markup.bg, { __call = function(_, ...) return markup.bg.color(...) end })
65 -- link markup(...) calls to markup.fg.color(...)
66 return setmetatable(markup, { __call = function(_, ...) return markup.fg.color(...) end })