File:
[LON-CAPA] /
loncom /
html /
adm /
jsMath /
extensions /
HTML.js
Revision
1.2:
download - view:
text,
annotated -
select for diffs
Wed May 17 22:19:32 2006 UTC (18 years, 4 months ago) by
albertel
Branches:
MAIN
CVS tags:
version_2_9_X,
version_2_9_99_0,
version_2_9_1,
version_2_9_0,
version_2_8_X,
version_2_8_99_1,
version_2_8_99_0,
version_2_8_2,
version_2_8_1,
version_2_8_0,
version_2_7_X,
version_2_7_99_1,
version_2_7_99_0,
version_2_7_1,
version_2_7_0,
version_2_6_X,
version_2_6_99_1,
version_2_6_99_0,
version_2_6_3,
version_2_6_2,
version_2_6_1,
version_2_6_0,
version_2_5_X,
version_2_5_99_1,
version_2_5_99_0,
version_2_5_2,
version_2_5_1,
version_2_5_0,
version_2_4_X,
version_2_4_99_0,
version_2_4_2,
version_2_4_1,
version_2_4_0,
version_2_3_X,
version_2_3_99_0,
version_2_3_2,
version_2_3_1,
version_2_3_0,
version_2_2_X,
version_2_2_99_1,
version_2_2_99_0,
version_2_2_2,
version_2_2_1,
version_2_2_0,
version_2_1_X,
version_2_1_99_3,
version_2_1_99_2,
version_2_1_99_1,
version_2_1_99_0,
version_2_12_X,
version_2_11_X,
version_2_11_5_msu,
version_2_11_5,
version_2_11_4_uiuc,
version_2_11_4_msu,
version_2_11_4,
version_2_11_3_uiuc,
version_2_11_3_msu,
version_2_11_3,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0,
version_2_10_X,
version_2_10_1,
version_2_10_0_RC2,
version_2_10_0_RC1,
version_2_10_0,
loncapaMITrelate_1,
language_hyphenation_merge,
language_hyphenation,
bz6209-base,
bz6209,
bz5969,
bz2851,
PRINT_INCOMPLETE_base,
PRINT_INCOMPLETE,
HEAD,
GCI_3,
GCI_2,
GCI_1,
BZ5971-printing-apage,
BZ5434-fox,
BZ4492-merge,
BZ4492-feature_horizontal_radioresponse
- jsmath 3.3
1: /*
2: * extensions/HTML.js
3: *
4: * Part of the jsMath package for mathematics on the web.
5: *
6: * This file implements a number of HTML-specific extensions to TeX,
7: * including \color, \style, \class, \unicode, etc. It will be loaded
8: * automatically when needed, or can be loaded by
9: *
10: * jsMath.Extension.Require('HTML');
11: *
12: * ---------------------------------------------------------------------
13: *
14: * Copyright 2005-2006 by Davide P. Cervone
15: *
16: * Licensed under the Apache License, Version 2.0 (the "License");
17: * you may not use this file except in compliance with the License.
18: * You may obtain a copy of the License at
19: *
20: * http://www.apache.org/licenses/LICENSE-2.0
21: *
22: * Unless required by applicable law or agreed to in writing, software
23: * distributed under the License is distributed on an "AS IS" BASIS,
24: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25: * See the License for the specific language governing permissions and
26: * limitations under the License.
27: */
28:
29: /********************************************************************/
30:
31: jsMath.Package(jsMath.Parser,{
32:
33: macros: {
34: color: 'Color',
35: href: 'Href',
36: 'class': 'Class',
37: style: 'Style',
38: cssId: 'CSSId',
39: unicode: 'Unicode'
40: },
41:
42: /*
43: * Show the argument in a particular color
44: */
45: Color: function (name) {
46: var color = this.GetArgument(this.cmd+name); if (this.error) return;
47: // check that it looks like a color?
48: this.AddHTML(name,['<span style="color: '+color+'">','</span>']);
49: },
50:
51: /*
52: * Make the argument be a link
53: */
54: Href: function (name) {
55: var href = this.GetArgument(this.cmd+name); if (this.error) return;
56: this.AddHTML(name,['<a class="link" href="'+href+'">','</a>']);
57: },
58:
59: /*
60: * Apply a CSS class to the argument
61: */
62: Class: function (name) {
63: var clss = this.GetArgument(this.cmd+name); if (this.error) return;
64: this.AddHTML(name,['<span class="'+clss+'">','</span>']);
65: },
66:
67: /*
68: * Apply a CSS style to the argument
69: */
70: Style: function (name) {
71: var style = this.GetArgument(this.cmd+name); if (this.error) return;
72: this.AddHTML(name,['<span style="'+style+'">','</span>']);
73: },
74:
75: /*
76: * Add a CSS element ID to the argument
77: */
78: CSSId: function (name) {
79: var id = this.GetArgument(this.cmd+name); if (this.error) return;
80: this.AddHTML(name,['<span id="'+id+'">','</span>']);
81: },
82:
83: /*
84: * Insert some raw HTML around the argument (this will not affect
85: * the spacing or other TeX features)
86: */
87: AddHTML: function (name,params) {
88: var data = this.mlist.data;
89: var arg = this.GetArgument(this.cmd+name); if (this.error) return;
90: arg = jsMath.Parse(arg,data.font,data.size,data.style);
91: if (arg.error) {this.Error(arg); return}
92: this.mlist.Add(jsMath.mItem.HTML(params[0]));
93: for (var i = 0; i < arg.mlist.Length(); i++) {this.mlist.Add(arg.mlist.Get(i))}
94: this.mlist.Add(jsMath.mItem.HTML(params[1]));
95: },
96:
97: /*
98: * Insert a unicode reference as an Ord atom. Its argument should
99: * be the unicode code point, e.g. \unicode{8211}, or \unicode{x203F}.
100: * You can also specify the height (offset from the x height) and depth
101: * in ems, together with a CSS class for the character, e.g.,
102: * \unicode{8211,class,.2,-.3}
103: */
104: Unicode: function (name) {
105: var arg = this.GetArgument(this.cmd+name); if (this.error) return;
106: arg = arg.split(','); arg[0] = '&#'+arg[0]+';';
107: if (!arg[1]) {arg[1] = 'normal'}
108: this.mlist.Add(jsMath.mItem.TextAtom('ord',arg[0],arg[1],arg[2],arg[3]));
109: }
110:
111: });
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>