History

Host MathML stylesheet in DevDocs

Thibaut Courouble committed 10 years ago

Commit a8bd4221 parent 4c28cb63 files · +218 −3Browse files

Unified · Split

3 files
  1. assets/javascripts/vendor/mathml.js +2 −2
  2. lib/app.rb +2 −1
  3. public/mathml.css +214 −0
assets/javascripts/vendor/mathml.js+2−2
@@ -1,6 +1,6 @@
11 /* This Source Code Form is subject to the terms of the Mozilla Public
22 * 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/.
3+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
44 * Adapted from: https://github.com/fred-wang/mathml.css */
55 /*jslint browser: true*/
66
@@ -18,7 +18,7 @@ · 11 unmodified lines
1818 if (Math.abs(box.height - 23) > 1 || Math.abs(box.width - 77) > 1) {
1919 // Insert the mathml.css stylesheet.
2020 link = document.createElement("link");
21− link.href = "http://fred-wang.github.io/mathml.css/mathml.css";
21+ link.href = "https://cdn.devdocs.io/mathml.css";
2222 link.rel = "stylesheet";
2323 document.head.appendChild(link);
2424 }
lib/app.rb+2−1
@@ -80,11 +80,12 @@ class App < Sinatra::Application · 79 unmodified lines
8080 use Rack::Deflater
8181 use Rack::Static,
8282 root: 'public',
83− urls: %w(/assets /docs/ /images /favicon.ico /robots.txt /opensearch.xml /manifest.webapp),
83+ urls: %w(/assets /docs/ /images /favicon.ico /robots.txt /opensearch.xml /manifest.webapp /mathml.css),
8484 header_rules: [
8585 [:all, {'Cache-Control' => 'no-cache, max-age=0'}],
8686 ['/assets', {'Cache-Control' => 'public, max-age=604800'}],
8787 ['/favicon.ico', {'Cache-Control' => 'public, max-age=86400'}],
88+ ['/mathml.css', {'Cache-Control' => 'public, max-age=604800'}],
8889 ['/images', {'Cache-Control' => 'public, max-age=86400'}] ]
8990
9091 sprockets.js_compressor = Uglifier.new output: { beautify: true, indent_level: 0 }
public/mathml.css+214−0
@@ -0,0 +1,214 @@
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+/* See https://github.com/fred-wang/mathml.css */
6+
7+@namespace "http://www.w3.org/1998/Math/MathML";
8+
9+/* math */
10+math {
11+ display: inline;
12+ text-indent: 0;
13+}
14+math[display="block"] {
15+ display: block;
16+ text-align: center;
17+}
18+
19+/* fraction */
20+mfrac {
21+ display: inline-block !important;
22+ vertical-align: -50%;
23+ border-collapse: collapse;
24+ text-align: center;
25+}
26+mfrac > * {
27+ display: block !important;
28+}
29+mfrac > * + * {
30+ display: inline-block !important;
31+ vertical-align: top;
32+}
33+mfrac:not([linethickness="0"]) > *:first-child {
34+ border-bottom: solid thin;
35+}
36+
37+/* sub/sup scripts */
38+msub > *:nth-child(2), msubsup > *:nth-child(2),
39+mmultiscripts > *:nth-child(2n+2),
40+mmultiscripts > mprescripts ~ *:nth-child(2n+3) {
41+ font-size: 0.8em;
42+ vertical-align: sub;
43+}
44+msup > *:nth-child(2), msubsup > *:nth-child(3),
45+mmultiscripts > *:nth-child(2n+3),
46+mmultiscripts > mprescripts ~ *:nth-child(2n+2) {
47+ font-size: 0.8em;
48+ vertical-align: super;
49+}
50+mprescripts:after {
51+ content: ";";
52+}
53+
54+/* under/over scripts */
55+munder, mover, munderover {
56+ display: inline-flex !important;
57+ flex-direction: column;
58+}
59+munder > *:nth-child(2), munderover > *:nth-child(2) {
60+ font-size: 0.8em;
61+ order: +1;
62+}
63+mover > *:nth-child(2), munderover > *:nth-child(3) {
64+ font-size: 0.8em;
65+ order: -1;
66+}
67+munder {
68+ vertical-align: text-top;
69+}
70+mover {
71+ vertical-align: text-bottom;
72+}
73+munderover {
74+ vertical-align: middle;
75+}
76+
77+/* roots */
78+msqrt, mroot {
79+ display: inline-flex !important;
80+ margin-left: .5em;
81+ vertical-align: middle;
82+ border-top: solid thin;
83+}
84+msqrt:before, mroot:before {
85+ margin-left: -.5em;
86+ content: "\221A";
87+}
88+mroot > *:nth-child(2) {
89+ margin-right: .25em;
90+ margin-left: -.75em;
91+ font-size: 0.8em;
92+ order: -1;
93+}
94+
95+/* menclose */
96+menclose {
97+ display: inline-table !important;
98+ border-collapse: separate;
99+ border-spacing: 0.4ex 0;
100+}
101+menclose[notation*="top"], menclose[notation*="actuarial"] {
102+ border-top: solid thin;
103+}
104+menclose[notation*="bottom"], menclose[notation*="madruwb"] {
105+ border-bottom: solid thin;
106+}
107+menclose[notation*="right"], menclose[notation*="actuarial"],
108+menclose[notation*="madruwb"] {
109+ border-right: solid thin;
110+}
111+menclose[notation*="left"] {
112+ border-left: solid thin;
113+}
114+menclose[notation*="box"], menclose[notation*="roundedbox"],
115+menclose[notation*="circle"] {
116+ border: solid thin;
117+}
118+menclose[notation*="roundedbox"] {
119+ border-radius: 15%;
120+}
121+menclose[notation*="circle"] {
122+ border-radius: 50%;
123+}
124+menclose[notation*="horizontalstrike"] {
125+ text-decoration: line-through;
126+}
127+
128+/* table */
129+mtable {
130+ display: inline-table !important;
131+ vertical-align: middle;
132+ text-align: center;
133+}
134+mtr {
135+ display: table-row !important;
136+}
137+mtd {
138+ display: table-cell !important;
139+ padding: 0 0.5ex;
140+}
141+
142+/* token elements */
143+mspace {
144+ margin: .2em;
145+}
146+mi {
147+ font-style: italic;
148+}
149+mo {
150+ margin-right: .2em;
151+ margin-left: .2em;
152+}
153+ms:before, ms:after {
154+ content:"\0022";
155+}
156+ms[lquote]:before {
157+ content: attr(lquote);
158+}
159+ms[rquote]:after {
160+ content: attr(rquote);
161+}
162+
163+/* mathvariants */
164+[mathvariant="bold"], [mathvariant="bold-italic"],
165+[mathvariant="bold-sans-serif"], [mathvariant="sans-serif-bold-italic"] {
166+ font-weight: bold;
167+ font-style: normal;
168+}
169+[mathvariant="monospace"] {
170+ font-family: monospace;
171+ font-style: normal;
172+}
173+[mathvariant="sans-serif"],
174+[mathvariant="bold-sans-serif"], [mathvariant="sans-serif-italic"],
175+[mathvariant="sans-serif-bold-italic"] {
176+ font-family: sans-serif;
177+ font-style: normal;
178+}
179+[mathvariant="italic"], [mathvariant="bold-italic"],
180+[mathvariant="sans-serif-italic"], [mathvariant="sans-serif-bold-italic"] {
181+ font-style: italic;
182+}
183+[mathvariant="normal"] {
184+ font-style: normal;
185+}
186+
187+/* mphantom */
188+mphantom {
189+ visibility: hidden;
190+}
191+
192+/* merror */
193+merror {
194+ outline: solid thin red;
195+}
196+merror:before {
197+ content: "Error: ";
198+}
199+
200+/* annotations */
201+semantics > *:first-child {
202+ display: inline;
203+}
204+annotation, annotation-xml {
205+ font-family: monospace;
206+ display: none !important;
207+}
208+math:active > semantics > *:first-child,
209+math:active > semantics > *:first-child {
210+ display: none !important;
211+}
212+math:active annotation:first-of-type {
213+ display: inline !important;
214+}