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.
4 Licensed under MIT License
5 * (c) 2013, Luke Bonham
6 * (c) 2009, Uli Schlachter
11 local string = { format = string.format }
12 local setmetatable = setmetatable
14 -- Lain markup util submodule
16 local markup = { fg = {}, bg = {} }
19 function markup.bold(text) return '<b>' .. text .. '</b>' end
20 function markup.italic(text) return '<i>' .. text .. '</i>' end
21 function markup.strike(text) return '<s>' .. text .. '</s>' end
22 function markup.underline(text) return '<u>' .. text .. '</u>' end
23 function markup.monospace(text) return '<tt>' .. text .. '</tt>' end
24 function markup.big(text) return '<big>' .. text .. '</big>' end
25 function markup.small(text) return '<small>' .. text .. '</small>' end
28 function markup.font(font, text)
29 return '<span font="' .. font .. '">' .. text ..'</span>'
32 -- Set the foreground.
33 function markup.fg.color(color, text)
34 return '<span foreground="' .. color .. '">' .. text .. '</span>'
37 -- Set the background.
38 function markup.bg.color(color, text)
39 return '<span background="' .. color .. '">' .. text .. '</span>'
42 -- Set foreground and background.
43 function markup.color(fg, bg, text)
44 return string.format('<span foreground="%s" background="%s">%s</span>', fg, bg, text)
47 -- Set font and foreground.
48 function markup.fontfg(font, fg, text)
49 return string.format('<span font="%s" foreground="%s">%s</span>', font, fg, text)
52 -- Set font and background.
53 function markup.fontbg(font, bg, text)
54 return string.format('<span font="%s" background="%s">%s</span>', font, bg, text)
57 -- Set font, foreground and background.
58 function markup.fontcolor(font, fg, bg, text)
59 return string.format('<span font="%s" foreground="%s" background="%s">%s</span>', font, fg, bg, text)
62 -- link markup.{fg,bg}(...) calls to markup.{fg,bg}.color(...)
63 setmetatable(markup.fg, { __call = function(_, ...) return markup.fg.color(...) end })
64 setmetatable(markup.bg, { __call = function(_, ...) return markup.bg.color(...) end })
66 -- link markup(...) calls to markup.fg.color(...)
67 return setmetatable(markup, { __call = function(_, ...) return markup.fg.color(...) end })