@@ -53,55 +53,53 @@ Elm.Native.Text.make = function(elm) {
5353
5454 function toText(str) { return Utils.txt(properEscape(JS.fromString(str))); }
5555
56− function addTag(tag) {
57− return function(text) {
58− return Utils.txt('<' + tag + '>' + text + '</' + tag + '>');
59− }
60− }
61−
62− function addStyle(style, value, text) {
63− return Utils.txt("<span style='" + style + ":" + value + "'>" + text + "</span>");
56+ function height(px, text) {
57+ return { style: 'font-size:' + px + 'px;', text:text }
6458 }
65−
6659 function typeface(name, text) {
67− return addStyle('font-family', JS.fromString(name), text);
60+ return { style: 'font-family:' + name + ';', text:text }
6861 }
6962 function monospace(text) {
70− return addStyle('font-family', 'monospace', text);
63+ return { style: 'font-family:monospace;', text:text }
7164 }
72− function size(px, text) { return addStyle('font-size', px + 'px', text) }
73− var header = addTag('h1');
74− function height(h, text) { return addStyle('font-size', h+'px', text) }
75− function italic(text) { return addStyle('font-style', 'italic', text) }
76− var bold = addTag('b');
77−
78− function extract(c) {
79− if (c._3 === 1) { return 'rgb(' + c._0 + ', ' + c._1 + ', ' + c._2 + ')'; }
80− return 'rgba(' + c._0 + ', ' + c._1 + ', ' + c._2 + ', ' + c._3 + ')';
65+ function italic(text) {
66+ return { style: 'font-style:italic;', text:text }
8167 }
82− function color(c, text) {
83− return addStyle('color', extract(c), text);
68+ function bold(text) {
69+ return { style: 'font-weight:bold;', text:text }
70+ }
71+ function link(href, text) {
72+ return { href: toText(href), text:text };
73+ }
74+ function underline(text) {
75+ return { line: ' underline', text:text };
76+ }
77+ function overline(text) {
78+ return { line: ' overline', text:text };
8479 }
85− function underline(text) { return addStyle('text-decoration', 'underline', text) }
86− function overline(text) { return addStyle('text-decoration', 'overline', text) }
8780 function strikeThrough(text) {
88− return addStyle('text-decoration', 'line-through', text);
81+ return { line: ' line-through', text:text };
8982 }
90− function link(href, text) {
91− return Utils.txt("<a href='" + toText(href) + "'>" + text + "</a>");
83+
84+ function color(c, text) {
85+ var color = (c._3 === 1)
86+ ? ('rgb(' + c._0 + ', ' + c._1 + ', ' + c._2 + ')')
87+ : ('rgba(' + c._0 + ', ' + c._1 + ', ' + c._2 + ', ' + c._3 + ')');
88+ return { style: 'color:' + color + ';', text:text };
9289 }
9390
9491 function position(align) {
95− return function(text) {
92+ function create(text) {
9693 var raw = {
9794 ctor:'RawHtml',
98− html: '<span style="text-align:' + align + ';">' + text + '</span>',
95+ html: Utils.makeText('text-align:' + align + ';', text),
9996 guid: null,
10097 args: [],
10198 };
10299 var pos = A2(Utils.htmlHeight, 0, raw);
103100 return A3(Element.newElement, pos._0, pos._1, raw);
104101 }
102+ return create;
105103 }
106104
107105 function markdown(text, guid) {
@@ -123,18 +121,18 @@ Elm.Native.Text.make = function(elm) {
123121 return A3(Element.newElement, pos._0, pos._1, raw);
124122 }
125123
124+ var text = position('left');
126125 function asText(v) {
127− return position('left')(monospace(toText(show(v))));
126+ return text(monospace(toText(show(v))));
128127 }
129128
130129 function plainText(v) {
131− return position('left')(toText(v));
130+ return text(toText(v));
132131 }
133132
134133 return elm.Native.Text.values = {
135134 toText: toText,
136135
137− header : header,
138136 height : F2(height),
139137 italic : italic,
140138 bold : bold,
@@ -149,7 +147,7 @@ Elm.Native.Text.make = function(elm) {
149147 justified : position('justify'),
150148 centered : position('center'),
151149 righted : position('right'),
152− text : position('left'),
150+ text : text,
153151 plainText : plainText,
154152 markdown : markdown,
155153