Skip to content

Commit 4fe111f

Browse files
committed
Add WebExtensions.
1 parent b4683fc commit 4fe111f

12 files changed

+271
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ config.log
1111
config.status
1212
unicode.xml
1313
examples/TeXZillaParser.class
14+
texzilla-web-extension.zip

Makefile.in

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ help:
2222
@echo "make tests-all"
2323
@echo " Run the unit tests with nodejs, phantomjs and slimerjs."
2424
@echo
25+
@echo "make extension"
26+
@echo " Package the Web Extension."
27+
@echo
2528
@echo "make release"
2629
@echo " Publish a new release of TeXZilla."
2730
@echo
@@ -109,6 +112,13 @@ minify: TeXZilla-min.js
109112

110113
all: tests build
111114

115+
texzilla-web-extension.zip: TeXZilla-min.js web-extension
116+
# Package the Web Extension.
117+
cp TeXZilla-min.js web-extension/tab/
118+
cd web-extension; @ZIP@ -r ../$@ *
119+
120+
extension: texzilla-web-extension.zip
121+
112122
clean:
113123
# Remove all generated files except unicode.xml and LaTeX-min.js
114124
rm -f chars.txt char-commands.txt commands.txt \

configure

+56-1
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ PACKAGE_URL=''
584584
ac_unique_file="TeXZilla.jison"
585585
ac_subst_vars='LTLIBOBJS
586586
LIBOBJS
587+
ZIP
587588
XSLTPROC
588589
SED
589590
PYTHON
@@ -617,6 +618,7 @@ infodir
617618
docdir
618619
oldincludedir
619620
includedir
621+
runstatedir
620622
localstatedir
621623
sharedstatedir
622624
sysconfdir
@@ -681,6 +683,7 @@ datadir='${datarootdir}'
681683
sysconfdir='${prefix}/etc'
682684
sharedstatedir='${prefix}/com'
683685
localstatedir='${prefix}/var'
686+
runstatedir='${localstatedir}/run'
684687
includedir='${prefix}/include'
685688
oldincludedir='/usr/include'
686689
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -933,6 +936,15 @@ do
933936
| -silent | --silent | --silen | --sile | --sil)
934937
silent=yes ;;
935938

939+
-runstatedir | --runstatedir | --runstatedi | --runstated \
940+
| --runstate | --runstat | --runsta | --runst | --runs \
941+
| --run | --ru | --r)
942+
ac_prev=runstatedir ;;
943+
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
944+
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
945+
| --run=* | --ru=* | --r=*)
946+
runstatedir=$ac_optarg ;;
947+
936948
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
937949
ac_prev=sbindir ;;
938950
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1070,7 +1082,7 @@ fi
10701082
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
10711083
datadir sysconfdir sharedstatedir localstatedir includedir \
10721084
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
1073-
libdir localedir mandir
1085+
libdir localedir mandir runstatedir
10741086
do
10751087
eval ac_val=\$$ac_var
10761088
# Remove trailing slashes.
@@ -1223,6 +1235,7 @@ Fine tuning of the installation directories:
12231235
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
12241236
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
12251237
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
1238+
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
12261239
--libdir=DIR object code libraries [EPREFIX/lib]
12271240
--includedir=DIR C header files [PREFIX/include]
12281241
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -2266,6 +2279,48 @@ fi
22662279
test -n "$XSLTPROC" && break
22672280
done
22682281

2282+
for ac_prog in zip
2283+
do
2284+
# Extract the first word of "$ac_prog", so it can be a program name with args.
2285+
set dummy $ac_prog; ac_word=$2
2286+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
2287+
$as_echo_n "checking for $ac_word... " >&6; }
2288+
if ${ac_cv_prog_ZIP+:} false; then :
2289+
$as_echo_n "(cached) " >&6
2290+
else
2291+
if test -n "$ZIP"; then
2292+
ac_cv_prog_ZIP="$ZIP" # Let the user override the test.
2293+
else
2294+
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
2295+
for as_dir in $PATH
2296+
do
2297+
IFS=$as_save_IFS
2298+
test -z "$as_dir" && as_dir=.
2299+
for ac_exec_ext in '' $ac_executable_extensions; do
2300+
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
2301+
ac_cv_prog_ZIP="$ac_prog"
2302+
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
2303+
break 2
2304+
fi
2305+
done
2306+
done
2307+
IFS=$as_save_IFS
2308+
2309+
fi
2310+
fi
2311+
ZIP=$ac_cv_prog_ZIP
2312+
if test -n "$ZIP"; then
2313+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ZIP" >&5
2314+
$as_echo "$ZIP" >&6; }
2315+
else
2316+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
2317+
$as_echo "no" >&6; }
2318+
fi
2319+
2320+
2321+
test -n "$ZIP" && break
2322+
done
2323+
22692324

22702325
ac_config_files="$ac_config_files Makefile"
22712326

configure.ac

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ AC_CHECK_PROGS(PKILL, pkill)
2222
AC_CHECK_PROGS(PYTHON, python)
2323
AC_CHECK_PROGS(SED, sed)
2424
AC_CHECK_PROGS(XSLTPROC, xsltproc)
25+
AC_CHECK_PROGS(ZIP, zip)
2526

2627
AC_CONFIG_FILES(Makefile)
2728
AC_OUTPUT

release.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ $NPM publish .
3636

3737
# Remove all but the files to include in the release.
3838
rm .gitignore
39-
ls | $EGREP -v "README-release.txt|TeXZilla.js|TeXZilla-min.js|examples|index.html" | xargs rm
39+
ls | $EGREP -v "README-release.txt|TeXZilla.js|TeXZilla-min.js|examples|index.html" | xargs rm -rf
4040

4141
# Set the version in the README-release.txt
4242
$SED -i s/RELEASENUMBER/$RELEASENUMBER/ README-release.txt

web-extension/background.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
browser.browserAction.onClicked.addListener(function() {
6+
browser.tabs.create({
7+
"url": "/tab/index.html"
8+
});
9+
});

web-extension/icons/icon-32.png

692 Bytes
Loading

web-extension/icons/icon-48.png

1.02 KB
Loading

web-extension/icons/icon-96.png

2.09 KB
Loading

web-extension/manifest.json

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"manifest_version": 2,
3+
"name": "TeXZilla",
4+
"version": "0.9.9.1",
5+
"description": "Add-on giving access to TeXZilla, a Unicode TeX-to-MathML converter.",
6+
"author": "Frédéric Wang",
7+
"homepage_url": "https://github.com/fred-wang/texzilla",
8+
"icons": {
9+
"48": "icons/icon-48.png",
10+
"96": "icons/icon-96.png"
11+
},
12+
13+
"background": {
14+
"scripts": ["background.js"]
15+
},
16+
17+
"browser_action": {
18+
"default_icon": "icons/icon-32.png",
19+
"default_title": "TeXZilla Editor"
20+
}
21+
}

web-extension/tab/index.html

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>TeXZilla</title>
5+
<meta charset="utf-8"/>
6+
<!-- This Source Code Form is subject to the terms of the Mozilla Public
7+
- License, v. 2.0. If a copy of the MPL was not distributed with this
8+
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
9+
<script type="text/javascript" src="./TeXZilla-min.js"></script>
10+
</head>
11+
<body>
12+
13+
<p>
14+
<select id="mode">
15+
<option value="display">Display Mode</option>
16+
<option value="inline">Inline Mode</option>
17+
</select>
18+
19+
<select id="dir">
20+
<option value="LTR">LTR</option>
21+
<option value="RTL">RTL</option>
22+
</select>
23+
24+
<select id="examples">
25+
<option value="" selected="selected">-- select an example --</option>
26+
<option value="\frac{x^2}{a^2} + \frac{y^2}{b^2} = 1">Ellipse Equation</option>
27+
<option value="\sum_{n=1}^{+\infty} \frac{1}{n^2} = \frac{\pi^2}{6}">Sum 1/n²</option>
28+
<option value="∑_{n=1}^{+∞} \frac{1}{n^2} = \frac{π^2}{6}">Sum 1/n² (Unicode)</option>
29+
<option value="x = \frac{-b\pm\sqrt{b^2-4ac}}{2a}">Quadratic Formula</option>
30+
<option value="س = \frac{-ب\pm\sqrt{ب^٢-٤اج}}{٢ا}">Quadratic Formula (Arabic)</option>
31+
<option value="f(x)=\sum_{n=-\infty}^\infty c_n e^{2\pi i(n/T) x} =\sum_{n=-\infty}^\infty \hat{f}(\xi_n) e^{2\pi i\xi_n x}\Delta\xi">Fourier Transform</option>
32+
<option value="\Gamma(t) = \lim_{n \to \infty} \frac{n! \; n^t}{t \; (t+1)\cdots(t+n)}= \frac{1}{t} \prod_{n=1}^\infty \frac{\left(1+\frac{1}{n}\right)^t}{1+\frac{t}{n}} = \frac{e^{-\gamma t}}{t} \prod_{n=1}^\infty \left(1 + \frac{t}{n}\right)^{-1} e^{\frac{t}{n}}">Gamma function</option>
33+
<option value="\mathfrak{sl}(n, \mathbb{F}) = \left\{ A \in \mathscr{M}_n(\mathbb{F}) : \operatorname{Tr}(A) = 0 \right\}">Lie Algebra</option>
34+
<option value="x^2 y^2">Mozilla MathML Torture Test 1</option>
35+
<option value="\multiscripts{_2}{F}{_3}">Mozilla MathML Torture Test 2</option>
36+
<option value="\frac{x+y^2}{k+1}">Mozilla MathML Torture Test 3</option>
37+
<option value="x+y^{\frac 2 {k+1}}">Mozilla MathML Torture Test 4</option>
38+
<option value="\frac{a}{b/2}">Mozilla MathML Torture Test 5</option>
39+
<option value="\displaystyle a_0 + \frac{1}{\displaystyle a_1+\frac{1}{\displaystyle a_2+\frac{1}{\displaystyle a_3+\frac{1}{\displaystyle a_4}}}}">Mozilla MathML Torture Test 6</option>
40+
<option value="a_0 + \frac{1}{a_1+\frac{1}{a_2+\frac{1}{a_3+\frac{1}{a_4}}}}">Mozilla MathML Torture Test 7</option>
41+
<option value="\binom{n}{k/2}">Mozilla MathML Torture Test 8</option>
42+
<option value="\binom{p}{2} x^2 y^{p-2} - \frac{1}{1-x} \frac{1}{1-x^2}">Mozilla MathML Torture Test 9</option>
43+
<option value="\sum_{\substack{
44+
0 \le i \le m \\
45+
0 &lt; j &lt; n
46+
}} {P(i,j)}">Mozilla MathML Torture Test 10</option>
47+
<option value="x^{2y}">Mozilla MathML Torture Test 11</option>
48+
<option value="\sum_{i=1}^p \sum_{j=1}^q \sum_{k=1}^r {a_{i j} b_{j k} c_{k i}}">Mozilla MathML Torture Test 12</option>
49+
<option value="\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+\sqrt{1+x}}}}}}}">Mozilla MathML Torture Test 13</option>
50+
<option value="\left( \frac{\partial^2}{\partial x^2} + \frac{\partial^2}{\partial y^2} \right) {| \varphi(x+ i y)|}^2 = 0">Mozilla MathML Torture Test 14</option>
51+
<option value="2^{2^{2^x}}">Mozilla MathML Torture Test 15</option>
52+
<option value="\int_1^x \frac{dt}{t}">Mozilla MathML Torture Test 16</option>
53+
<option value="\iint_D {dx dy}">Mozilla MathML Torture Test 17</option>
54+
<option value="f(x) =
55+
\begin{cases}
56+
1/3 & \text{if} \quad 0 \leq x \leq 1; \\
57+
2/3 & \text{if} \quad 3 \leq x \leq 4; \\
58+
0 & \text{elsewhere}.
59+
\end{cases}
60+
">Mozilla MathML Torture Test 18</option>
61+
<option value="\overset{k \, \text{times}}{\overbrace{x+\dots+x}}">Mozilla MathML Torture Test 19</option>
62+
<option value="y_{x^2}">Mozilla MathML Torture Test 20</option>
63+
<option value="\sum_{p \, \text{prime}} {f(p)} = \int_{t > 1} {f(t) d\pi(t)} ">Mozilla MathML Torture Test 21</option>
64+
<option value="\{\underset{k+l \, \text{elements}}{
65+
\underbrace{
66+
\overset{k \, a\text{'s}}{\overbrace{\mathrlap \phantom{(} a,\dots,a}},
67+
\overset{l \, b\text{'s}}{\overbrace{\mathrlap \phantom{(} b,\dots,b}}
68+
}}\}">Mozilla MathML Torture Test 22</option>
69+
<option value="\begin{pmatrix}
70+
\begin{pmatrix} a & b \\ c & d \end{pmatrix} &
71+
\begin{pmatrix} e & f \\ g & h \end{pmatrix} \\
72+
0 &
73+
\begin{pmatrix} i & j \\ k & l \end{pmatrix}
74+
\end{pmatrix}">Mozilla MathML Torture Test 23</option>
75+
<option value="\det
76+
\begin{vmatrix}
77+
c_0 & c_1 & c_2 & \dots & c_n \\
78+
c_1 & c_2 & c_3 & \dots & c_{n+1} \\
79+
c_2 & c_3 & c_4 & \dots & c_{n+2} \\
80+
\vdots & \vdots & \vdots & & \vdots \\
81+
c_n & c_{n+1} & c_{n+2} & \dots & c_{2n}
82+
\end{vmatrix}
83+
> 0">Mozilla MathML Torture Test 24</option>
84+
<option value="y_{x_2}">Mozilla MathML Torture Test 25</option>
85+
<option value="x^31415_92 + \pi">Mozilla MathML Torture Test 26</option>
86+
<option value="x^{z^d_c}_{y_b^a}">Mozilla MathML Torture Test 27</option>
87+
<option value="y_3'''">Mozilla MathML Torture Test 28</option>
88+
<option value="\begin{aligned}
89+
\dot{x} & = \sigma(y-x) \\
90+
\dot{y} & = \rho x - y - xz \\
91+
\dot{z} & = -\beta z + xy
92+
\end{aligned}">MathJax - The Lorenz Equations</option>
93+
<option value="\left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)">MathJax - The Cauchy-Schwarz Inequality</option>
94+
<option value="\mathbf{V}_1 \times \mathbf{V}_2 = \begin{vmatrix}
95+
\mathbf{i} & \mathbf{j} & \mathbf{k} \\
96+
\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
97+
\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0
98+
\end{vmatrix}">MathJax - A Cross Product Formula</option>
99+
<option value="P(E) = {n \choose k} p^k (1-p)^{ n-k}">MathJax - The probability of getting k heads when flipping n coins</option>
100+
<option value="\frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} =
101+
1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}}
102+
{1+\frac{e^{-8\pi}} {1+\ldots} } } }">MathJax - An Identity of Ramanujan</option>
103+
<option value="1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots =
104+
\prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})},
105+
\quad\quad \text{for} \quad |q| < 1.">MathJax - A Rogers-Ramanujan Identity</option>
106+
<option value="\begin{aligned}
107+
\nabla \times \vec{\mathbf{B}} -\, \frac1c\, \frac{\partial\vec{\mathbf{E}}}{\partial t} & = \frac{4\pi}{c}\vec{\mathbf{j}} \\ \nabla \cdot \vec{\mathbf{E}} & = 4 \pi \rho \\
108+
\nabla \times \vec{\mathbf{E}}\, +\, \frac1c\, \frac{\partial\vec{\mathbf{B}}}{\partial t} & = \vec{\mathbf{0}} \\
109+
\nabla \cdot \vec{\mathbf{B}} & = 0 \end{aligned}">MathJax - Maxwell’s Equations</option>
110+
</select>
111+
</p>
112+
<textarea id="input" style="width: 100%;" rows="10" dir="ltr"></textarea>
113+
114+
<div id="output"></div>
115+
116+
<script type="text/javascript" src="./index.js"></script>
117+
118+
</body>
119+
</html>

web-extension/tab/index.js

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
function update(aValue)
6+
{
7+
var input = document.getElementById("input");
8+
var output = document.getElementById("output");
9+
while (output.firstChild)
10+
output.removeChild(output.firstChild);
11+
if (aValue) input.value = aValue;
12+
try {
13+
output.style.color = "inherit";
14+
var math = TeXZilla.
15+
toMathML(input.value,
16+
document.getElementById("mode").value === "display",
17+
document.getElementById("dir").value === "RTL", true);
18+
output.appendChild(math);
19+
} catch(e) {
20+
output.style.color = "red";
21+
output.textContent = input.value;
22+
}
23+
}
24+
25+
document.getElementById("mode").addEventListener("change", function() {
26+
var math = document.getElementById("output").firstElementChild;
27+
if (math) {
28+
math.setAttribute("display",
29+
document.getElementById("mode").value === "display" ?
30+
"block" : "inline");
31+
} else {
32+
update();
33+
}
34+
});
35+
36+
document.getElementById("dir").addEventListener("change", function() {
37+
var math = document.getElementById("output").firstElementChild;
38+
if (math) {
39+
math.setAttribute("dir",
40+
document.getElementById("dir").value === "RTL" ?
41+
"rtl" : "ltr");
42+
} else {
43+
update();
44+
}
45+
});
46+
47+
document.getElementById("examples").addEventListener("change", function(event) {
48+
update(event.currentTarget.value);
49+
});
50+
51+
document.getElementById("input").addEventListener("input", function() {
52+
update();
53+
});

0 commit comments

Comments
 (0)