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