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
4 * (c) 2013, Luke Bonham
5 * (c) 2009, Uli Schlachter
10 local string = { format = string.format }
11 local setmetatable = setmetatable
13 -- Lain markup util submodule
15 local markup = { fg = {}, bg = {} }
18 function markup.bold(text) return '<b>' .. text .. '</b>' end
19 function markup.italic(text) return '<i>' .. text .. '</i>' end
20 function markup.strike(text) return '<s>' .. text .. '</s>' end
21 function markup.underline(text) return '<u>' .. text .. '</u>' end
22 function markup.monospace(text) return '<tt>' .. text .. '</tt>' end
23 function markup.big(text) return '<big>' .. text .. '</big>' end
24 function markup.small(text) return '<small>' .. text .. '</small>' end
27 function markup.font(font, text)
28 return '<span font="' .. font .. '">' .. text ..'</span>'
31 -- Set the foreground.
32 function markup.fg.color(color, text)
33 return '<span foreground="' .. color .. '">' .. text .. '</span>'
36 -- Set the background.
37 function markup.bg.color(color, text)
38 return '<span background="' .. color .. '">' .. text .. '</span>'
41 -- Set foreground and background.
42 function markup.color(fg, bg, text)
43 return string.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 string.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 string.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 string.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 })