├── .gitignore ├── package.json ├── README.md └── Gruntfile.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "MathJax-grunt-cleaner", 3 | "version": "0.1.0", 4 | "author": "MathJax Consortium", 5 | "private": true, 6 | "devDependencies": { 7 | "grunt": "^0.4.5", 8 | "grunt-contrib-clean": "^0.6.0", 9 | "grunt-regex-replace": "^0.2.6", 10 | "matchdep": "*" 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MathJax-grunt-cleaner 2 | 3 | A grunt file to reduce the footprint of a MathJax installation 4 | 5 | * Fetch a copy of MathJax `wget https://github.com/mathjax/MathJax/archive/master.zip && unzip master.zip` 6 | * copy & rename the `template` task 7 | * comment out the components you want to keep (perhaps **counterintuitive**) 8 | 9 | See the comments in file for more details and caveats. -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /* 2 | MathJax-grunt-cleaner 3 | ===================== 4 | A grunt file to reduce the footprint of a MathJax installation 5 | 6 | Latest version at https://github.com/pkra/MathJax-grunt-cleaner 7 | 8 | Copyright (c) 2014 Mathjax Consortium 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | */ 26 | 27 | module.exports = function(grunt) { 28 | "use strict"; 29 | // # Notes # 30 | // NEVER remove: 31 | // 32 | // * LICENSE -- the Apache license. 33 | // * jax/element/mml -- this implements MathJax"s internal format. Keep either the packed or unpacked copy. 34 | // 35 | 36 | grunt.initConfig({ 37 | pkg: grunt.file.readJSON("package.json"), 38 | clean: { 39 | // 40 | // ## Early choices 41 | // `unpacked` for development 42 | // ``packed` for production 43 | unpacked: [ 44 | "unpacked" 45 | ], 46 | packed: [ 47 | "config", 48 | "docs", 49 | "extensions", 50 | "jax", 51 | "localization", 52 | "MathJax.js" 53 | ], 54 | // If you don"t need combined configuration files or want to build your own: 55 | allConfigs: [ 56 | "config", 57 | "unpacked/config" 58 | ], 59 | // 60 | // ## Choosing a font 61 | // See http://docs.mathjax.org/en/latest/font-support.html#font-configuration for background information 62 | // 63 | // 1. Remove font files and font data for fonts you won"t use. 64 | // **IMPORTANT.** Make sure to prevent fallbacks and local fonts in your configuration! 65 | // 66 | // 67 | fontAsana: [ 68 | "fonts/HTML-CSS/Asana-Math", 69 | "jax/output/HTML-CSS/fonts/Asana-Math", 70 | "unpacked/jax/output/HTML-CSS/fonts/Asana-Math", 71 | "jax/output/SVG/fonts/Asana-Math", 72 | "unpacked/jax/output/SVG/fonts/Asana-Math" 73 | ], 74 | fontGyrePagella: [ 75 | "fonts/HTML-CSS/Gyre-Pagella", 76 | "jax/output/HTML-CSS/fonts/Gyre-Pagella", 77 | "unpacked/jax/output/HTML-CSS/fonts/Gyre-Pagella", 78 | "jax/output/SVG/fonts/Gyre-Pagella", 79 | "unpacked/jax/output/SVG/fonts/Gyre-Pagella" 80 | ], 81 | fontGyreTermes: [ 82 | "fonts/HTML-CSS/Gyre-Termes", 83 | "jax/output/HTML-CSS/fonts/Gyre-Termes", 84 | "unpacked/jax/output/HTML-CSS/fonts/Gyre-Termes", 85 | "jax/output/SVG/fonts/Gyre-Termes", 86 | "unpacked/jax/output/SVG/fonts/Gyre-Termes" 87 | ], 88 | fontLatinModern: [ 89 | "fonts/HTML-CSS/Latin-Modern", 90 | "jax/output/HTML-CSS/fonts/Latin-Modern", 91 | "unpacked/jax/output/HTML-CSS/fonts/Latin-Modern", 92 | "jax/output/SVG/fonts/Latin-Modern", 93 | "unpacked/jax/output/SVG/fonts/Latin-Modern" 94 | ], 95 | fontNeoEuler: [ 96 | "fonts/HTML-CSS/Neo-Euler", 97 | "jax/output/HTML-CSS/fonts/Neo-Euler", 98 | "unpacked/jax/output/HTML-CSS/fonts/Neo-Euler", 99 | "jax/output/SVG/fonts/Neo-Euler", 100 | "unpacked/jax/output/SVG/fonts/Neo-Euler" 101 | ], 102 | fontStix: [ 103 | "fonts/HTML-CSS/STIX", 104 | "jax/output/HTML-CSS/fonts/STIX", 105 | "unpacked/jax/output/HTML-CSS/fonts/STIX", 106 | "jax/output/SVG/fonts/STIX", 107 | "unpacked/jax/output/SVG/fonts/STIX" 108 | ], 109 | fontStixWeb: [ 110 | "fonts/HTML-CSS/STIX-Web", 111 | "jax/output/HTML-CSS/fonts/STIX-Web", 112 | "unpacked/jax/output/HTML-CSS/fonts/STIX-Web", 113 | "jax/output/SVG/fonts/STIX-Web", 114 | "unpacked/jax/output/SVG/fonts/STIX-Web" 115 | ], 116 | fontTeX: [ 117 | "fonts/HTML-CSS/TeX", 118 | "jax/output/HTML-CSS/fonts/TeX", 119 | "unpacked/jax/output/HTML-CSS/fonts/TeX", 120 | "jax/output/SVG/fonts/TeX", 121 | "unpacked/jax/output/SVG/fonts/TeX" 122 | ], 123 | // 124 | // Remove font formats 125 | // If you know you only need a specific format of your remaining fonts (e.g., woff), then you can delete the others. 126 | dropFonts: [ // if you use SVG output, you can drop all font formats (SVG output uses the data in `jax/output/SVG/fonts/...`) 127 | "fonts" 128 | ], 129 | eot: [ 130 | "fonts/**/eot" 131 | ], 132 | otf: [ 133 | "fonts/**/otf" 134 | ], 135 | png: [ 136 | "fonts/**/png" 137 | ], 138 | svg: [ // **NOT** related to the SVG output! 139 | "fonts/**/svg" 140 | ], 141 | woff: [ 142 | "fonts/**/woff" 143 | ], 144 | // ## Choose the input 145 | // Remove input that you don"t need. 146 | // **Note.** This includes combined configuration files. 147 | asciimathInput: [ 148 | "config/AM*", 149 | "config/TeX-MML-AM*", 150 | "jax/input/AsciiMath", 151 | "unpacked/config/AM*", 152 | "unpacked/config/TeX-MML-AM*", 153 | "unpacked/jax/input/AsciiMath" 154 | ], 155 | mathmlInput: [ 156 | "config/MML*", 157 | "config/TeX-MML*", 158 | "config/TeX-AMS-MML*", 159 | "jax/input/MathML", 160 | "unpacked/config/MathML*", 161 | "unpacked/jax/input/MathML" 162 | ], 163 | texInput: [ 164 | "config/TeX*", 165 | "jax/input/TeX", 166 | "unpacked/config/TeX*", 167 | "unpacked/jax/input/TeX" 168 | ], 169 | // ## Extensions 170 | extensionsAsciimath: [ 171 | "extensions/asciimath2jax.js", 172 | "unpacked/extensions/asciimath2jax.js" 173 | ], 174 | extensionsMathml: [ 175 | "extensions/MathML", 176 | "extensions/mml2jax.js", 177 | "unpacked/extensions/MathML", 178 | "unpacked/extensions/mml2jax.js" 179 | ], 180 | extensionsTeX: [ 181 | "extensions/TeX", 182 | "extensions/jsMath2jax.js", 183 | "extensions/tex2jax.js", 184 | "unpacked/extensions/TeX", 185 | "unpacked/extensions/jsMath2jax.js", 186 | "unpacked/extensions/tex2jax.js" 187 | ], 188 | extensionHtmlCss: [ 189 | "extensions/HTML-CSS", 190 | "unpacked/extensions/HTML-CSS" 191 | ], 192 | // ## Choose Output 193 | htmlCssOutput: [ 194 | "config/*HTMLorMML.js", 195 | "config/*HTMLorMML-full.js", 196 | "unpacked/config/*HTMLorMML.js", 197 | "unpacked/config/*HTMLorMML-full.js", 198 | "jax/output/HTML-CSS", 199 | "unpacked/jax/output/HTML-CSS" 200 | ], 201 | mathmlOutput: [ 202 | "config/*HTMLorMML.js", 203 | "config/*HTMLorMML-full.js", 204 | "unpacked/config/*HTMLorMML.js", 205 | "unpacked/config/*HTMLorMML-full.js", 206 | "jax/output/NativeMML", 207 | "unpacked/jax/output/NativeMML" 208 | ], 209 | svgOutput: [ 210 | "config/*SVG.js", 211 | "config/*SVG-full.js", 212 | "unpacked/config/*SVG.js", 213 | "unpacked/config/*SVG-full.js", 214 | "jax/output/SVG", 215 | "unpacked/jax/output/SVG" 216 | ], 217 | commonHtmlOutput: [ 218 | "configs/*CHTML.js", 219 | "configs/*CHTML-full.js", 220 | "unpacked/config/*CHTML.js", 221 | "unpacked/configs/*CHTML-full.js", 222 | "jax/output/CommonHTML", 223 | "unpacked/jax/output/CommonHTML", 224 | "extensions/CHTML-preview.js", 225 | "unpacked/extensions/CHTML-preview.js" 226 | ], 227 | previewHtmlOutput: [ 228 | "jax/output/PreviewHTML", 229 | "unpacked/jax/output/PreviewHTML", 230 | "extensions/fast-preview.js", 231 | "unpacked/extensions/fast-preview.js", 232 | "extensions/CHTML-preview.js", 233 | "unpacked/extensions/CHTML-preview.js" 234 | ], 235 | plainSourceOutput: [ 236 | "jax/output/PlainSource", 237 | "unpacked/jax/output/PlainSource" 238 | ], 239 | // ## Locales 240 | // Removes all locale files. Change this as needed to keep your preferred language. 241 | // **NOTE.** English strings are hardcoded. 242 | // **NOTE.** If you fix the locale, drop the menu entry: http://docs.mathjax.org/en/latest/options/MathMenu.html#configure-mathmenu 243 | locales: [ 244 | "localization", 245 | "unpacked/localization" 246 | ], 247 | // ## Misc. 248 | miscConfig: [ 249 | "config/local", 250 | "unpacked/config/local", 251 | "config/Accessible-full.js", 252 | "unpacked/config/Accessible-full.js", 253 | "config/Accessible.js", 254 | "unpacked/config/Accessible.js", 255 | "config/default.js", 256 | "unpacked/config/default.js", 257 | "config/Safe.js", 258 | "unpacked/config/Safe.js" 259 | ], 260 | a11yExtensions: [ 261 | "extensions/AssistiveMML.js", 262 | "unpacked/extensions/AssistiveMML.js" 263 | ], 264 | miscExtensions: [ 265 | "extensions/FontWarnings.js", 266 | "extensions/HelpDialog.js", 267 | "extensions/MatchWebFonts.js", 268 | "extensions/MathEvents.js", 269 | "extensions/MathMenu.js", 270 | "extensions/MathZoom.js", 271 | "extensions/Safe.js", 272 | "extensions/CHTML-preview.js", 273 | // "extensions/toMathML.js", // only remove `toMathML.js` if you know exactly what you are doing. 274 | "unpacked/extensions/FontWarnings.js", 275 | "unpacked/extensions/HelpDialog.js", 276 | "unpacked/extensions/MatchWebFonts.js", 277 | "unpacked/extensions/MathEvents.js", 278 | "unpacked/extensions/MathMenu.js", 279 | "unpacked/extensions/MathZoom.js", 280 | "unpacked/extensions/Safe.js", 281 | "unpacked/extensions/CHTML-preview.js" 282 | // "unpacked/extensions/toMathML.js", // only remove `toMathML.js` if you know exactly what you are doing. 283 | ], 284 | images: [ 285 | "images" // these are used in the menu. Removing them will give you 404 errors but nothing will break. 286 | ], 287 | notcode: [ 288 | ".gitignore", 289 | "docs", 290 | "test", 291 | "CONTRIBUTING.md", 292 | "README-branch.txt", 293 | "README.md", 294 | "bower.json", 295 | "composer.json", 296 | ".npmignore", 297 | "package.json" 298 | ] 299 | }, 300 | "regex-replace": { 301 | // disable image fonts in default HTML-CSS config 302 | noImageFont: { 303 | src: ['unpacked/jax/output/HTML-CSS/config.js'], 304 | actions: [ 305 | { 306 | name: 'nullImageFont', 307 | search: /imageFont:[^,]+,/, 308 | replace: 'imageFont: null,', 309 | } 310 | ] 311 | } 312 | } 313 | }); 314 | 315 | grunt.loadNpmTasks("grunt-contrib-clean"); 316 | grunt.loadNpmTasks('grunt-regex-replace'); 317 | 318 | grunt.registerTask("component", [ 319 | // components-mathjax excludes only PNG fonts 320 | "regex-replace:noImageFont", 321 | "clean:png", 322 | ]); 323 | 324 | grunt.registerTask("template", [ 325 | // **Notes** on the template. When instructions say "Pick one", this means commenting out one item (so that it"s not cleaned). 326 | // 327 | // Early choices. 328 | "clean:unpacked", 329 | "clean:packed", // pick one -- packed for production, unpacked for development. 330 | "clean:allConfigs", // if you do not need any combined configuration files. 331 | // Fonts. Pick at least one! Check notes above on configurations. 332 | "clean:fontAsana", 333 | "clean:fontGyrePagella", 334 | "clean:fontGyreTermes", 335 | "clean:fontLatinModern", 336 | "clean:fontNeoEuler", 337 | "clean:fontStix", 338 | "clean:fontStixWeb", 339 | "clean:fontTeX", 340 | // Font formats. Pick at least one (unless you use SVG output; then clean all). 341 | "clean:dropFonts", // when using SVG output 342 | "clean:eot", 343 | "clean:otf", 344 | "clean:png", 345 | "clean:svg", 346 | "clean:woff", 347 | // Input. Pick at least one. 348 | "clean:asciimathInput", 349 | "clean:mathmlInput", 350 | "clean:texInput", 351 | // Output 352 | "clean:htmlCssOutput", 353 | "clean:mathmlOutput", 354 | "clean:svgOutput", 355 | // Extensions. You probably want to leave the set matching your choices. 356 | "clean:extensionsAsciimath", 357 | "clean:extensionsMathml", 358 | "clean:extensionsTeX", 359 | "clean:extensionHtmlCss", 360 | // Other items 361 | "clean:locales", 362 | "clean:miscConfig", 363 | // "clean:miscExtensions", // you probably want that 364 | "clean:images", 365 | "clean:notcode" 366 | ]); 367 | grunt.registerTask("MML_SVG_TeX", [ 368 | // Early choices. 369 | "clean:unpacked", 370 | // "clean:packed", // pick one -- packed for production, unpacked for development. 371 | "clean:allConfigs", // if you do not need any combined configuration files. 372 | // Fonts. Pick at least one! Check notes above on configurations. 373 | "clean:fontAsana", 374 | "clean:fontGyrePagella", 375 | "clean:fontGyreTermes", 376 | "clean:fontLatinModern", 377 | "clean:fontNeoEuler", 378 | "clean:fontStix", 379 | "clean:fontStixWeb", 380 | // "clean:fontTeX", 381 | // Font formats. Pick at least one (unless you use SVG output; then clean all). 382 | "clean:dropFonts", // when using SVG output 383 | "clean:eot", 384 | "clean:otf", 385 | "clean:png", 386 | "clean:svg", 387 | "clean:woff", 388 | // Input. Pick at least one. 389 | "clean:asciimathInput", 390 | // "clean:mathmlInput", 391 | "clean:texInput", 392 | // Output 393 | "clean:htmlCssOutput", 394 | "clean:mathmlOutput", 395 | // "clean:svgOutput", 396 | // Extensions. You probably want to leave the set matching your choices. 397 | "clean:extensionsAsciimath", 398 | // "clean:extensionsMathml", 399 | "clean:extensionsTeX", 400 | "clean:extensionHtmlCss", 401 | // Other items 402 | "clean:locales", 403 | "clean:miscConfig", 404 | // "clean:miscExtensions", // you probably want that 405 | "clean:images", 406 | "clean:notcode" 407 | ]); 408 | grunt.registerTask("mjNode", [ 409 | "clean:packed", 410 | "clean:allConfigs", 411 | "clean:dropFonts", 412 | "clean:htmlCssOutput", 413 | "clean:locales", 414 | "clean:miscConfig", 415 | "clean:images", 416 | "clean:notcode", 417 | "clean:miscExtensions" 418 | ]); 419 | }; 420 | --------------------------------------------------------------------------------