2012-05-22 22:07:21 +00:00
|
|
|
|
|
|
|
var Text = function() {
|
|
|
|
var fromString = function(elmList) {
|
|
|
|
if (typeof elmList === "string") return elmList;
|
|
|
|
var a = [];
|
|
|
|
while (elmList[0] === "Cons") {
|
|
|
|
a.push(elmList[1]);
|
|
|
|
elmList = elmList[2];
|
|
|
|
}
|
2012-06-11 11:14:19 +00:00
|
|
|
return Data.String.properEscape(a.join(''));
|
2012-05-22 22:07:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var addTag = function(tag) { return function(text) {
|
|
|
|
return '<' + tag + '>' + text + '</' + tag + '>';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var addStyle = function(style, value) { return function(text) {
|
|
|
|
return "<span style='" + style + ":" + value + "'>" + text + "</span>";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
var typeface = function(name) { return addStyle('font-family', name); };
|
|
|
|
var size = function(px) {
|
|
|
|
return addStyle('font-size', px + 'px');
|
|
|
|
};
|
|
|
|
var header = addTag('h1');
|
|
|
|
var height = function(h) { return addStyle('font-size', h+'em'); }
|
|
|
|
var italic = addStyle('font-style', 'italic');
|
|
|
|
var bold = addTag('b');
|
|
|
|
var color = function(c) {
|
|
|
|
return addStyle('color', Color.Internal.extract(c));
|
|
|
|
};
|
|
|
|
var underline = addStyle('text-decoration', 'underline');
|
|
|
|
var overline = addStyle('text-decoration', 'overline');
|
|
|
|
var strikeThrough = addStyle('text-decoration', 'line-through');
|
|
|
|
var link = function(href) { return function(text) {
|
|
|
|
return "<a href='" + fromString(href) + "'>" + text + "</a>";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
return {fromString : fromString,
|
|
|
|
toText: fromString,
|
|
|
|
header : header,
|
|
|
|
height : height,
|
|
|
|
italic : italic,
|
|
|
|
bold : bold,
|
|
|
|
underline : underline,
|
|
|
|
overline : overline,
|
|
|
|
strikeThrough : strikeThrough,
|
|
|
|
monospace : typeface('monospace'),
|
|
|
|
color : color,
|
|
|
|
link : link };
|
2012-04-20 03:10:25 +00:00
|
|
|
}();
|