Merge remote-tracking branch 'katex-upstream/gh-pages'

This commit is contained in:
Georges Dupéron 2017-01-16 02:29:33 +01:00
commit e2ac677fa5
7 changed files with 287 additions and 9 deletions

35
bower_components/katex/bower.json vendored Normal file
View File

@ -0,0 +1,35 @@
{
"name": "KaTeX",
"version": "0.7.0",
"main": [
"dist/katex.min.js",
"dist/katex.min.css"
],
"homepage": "http://khan.github.io/KaTeX/",
"description": "Fast math typesetting for the web.",
"moduleType": [
"amd",
"globals",
"node"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/Khan/KaTeX.git"
},
"ignore": [
"**/.*",
"/*.txt",
"/*.js",
"/*.md",
"/package.json",
"/Makefile",
"/build",
"/test",
"/src",
"/contrib",
"/dockers",
"/metrics",
"/static"
]
}

View File

@ -16,8 +16,8 @@ KaTeX supports all major browsers, including Chrome, Safari, Firefox, Opera, and
You can [download KaTeX](https://github.com/khan/katex/releases) and host it on your server or include the `katex.min.js` and `katex.min.css` files on your page directly from a CDN:
```html
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js"></script>
```
#### In-browser rendering

View File

@ -1 +1 @@
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.renderMathInElement=e()}})(function(){var e,t,r;return function n(e,t,r){function a(o,l){if(!t[o]){if(!e[o]){var f=typeof require=="function"&&require;if(!l&&f)return f(o,!0);if(i)return i(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var s=t[o]={exports:{}};e[o][0].call(s.exports,function(t){var r=e[o][1][t];return a(r?r:t)},s,s.exports,n,e,t,r)}return t[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)a(r[o]);return a}({1:[function(e,t,r){var n=e("./splitAtDelimiters");var a=function(e,t){var r=[{type:"text",data:e}];for(var a=0;a<t.length;a++){var i=t[a];r=n(r,i.left,i.right,i.display||false)}return r};var i=function(e,t){var r=a(e,t);var n=document.createDocumentFragment();for(var i=0;i<r.length;i++){if(r[i].type==="text"){n.appendChild(document.createTextNode(r[i].data))}else{var o=document.createElement("span");var l=r[i].data;try{katex.render(l,o,{displayMode:r[i].display})}catch(f){if(!(f instanceof katex.ParseError)){throw f}console.error("KaTeX auto-render: Failed to parse `"+r[i].data+"` with ",f);n.appendChild(document.createTextNode(r[i].rawData));continue}n.appendChild(o)}}return n};var o=function(e,t,r){for(var n=0;n<e.childNodes.length;n++){var a=e.childNodes[n];if(a.nodeType===3){var l=i(a.textContent,t);n+=l.childNodes.length-1;e.replaceChild(l,a)}else if(a.nodeType===1){var f=r.indexOf(a.nodeName.toLowerCase())===-1;if(f){o(a,t,r)}}}};var l={delimiters:[{left:"$$",right:"$$",display:true},{left:"\\[",right:"\\]",display:true},{left:"\\(",right:"\\)",display:false}],ignoredTags:["script","noscript","style","textarea","pre","code"]};var f=function(e){var t;var r;for(var n=1,a=arguments.length;n<a;n++){t=arguments[n];for(r in t){if(Object.prototype.hasOwnProperty.call(t,r)){e[r]=t[r]}}}return e};var d=function(e,t){if(!e){throw new Error("No element provided to render")}t=f({},l,t);o(e,t.delimiters,t.ignoredTags)};t.exports=d},{"./splitAtDelimiters":2}],2:[function(e,t,r){var n=function(e,t,r){var n=r;var a=0;var i=e.length;while(n<t.length){var o=t[n];if(a<=0&&t.slice(n,n+i)===e){return n}else if(o==="\\"){n++}else if(o==="{"){a++}else if(o==="}"){a--}n++}return-1};var a=function(e,t,r,a){var i=[];for(var o=0;o<e.length;o++){if(e[o].type==="text"){var l=e[o].data;var f=true;var d=0;var s;s=l.indexOf(t);if(s!==-1){d=s;i.push({type:"text",data:l.slice(0,d)});f=false}while(true){if(f){s=l.indexOf(t,d);if(s===-1){break}i.push({type:"text",data:l.slice(d,s)});d=s}else{s=n(r,l,d+t.length);if(s===-1){break}i.push({type:"math",data:l.slice(d+t.length,s),rawData:l.slice(d,s+r.length),display:a});d=s+r.length}f=!f}i.push({type:"text",data:l.slice(d)})}else{i.push(e[o])}}return i};t.exports=a},{}]},{},[1])(1)});
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.renderMathInElement=e()}})(function(){var e,t,r;return function n(e,t,r){function a(o,l){if(!t[o]){if(!e[o]){var f=typeof require=="function"&&require;if(!l&&f)return f(o,!0);if(i)return i(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var s=t[o]={exports:{}};e[o][0].call(s.exports,function(t){var r=e[o][1][t];return a(r?r:t)},s,s.exports,n,e,t,r)}return t[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)a(r[o]);return a}({1:[function(e,t,r){var n=e("./splitAtDelimiters");var a=function(e,t){var r=[{type:"text",data:e}];for(var a=0;a<t.length;a++){var i=t[a];r=n(r,i.left,i.right,i.display||false)}return r};var i=function(e,t){var r=a(e,t);var n=document.createDocumentFragment();for(var i=0;i<r.length;i++){if(r[i].type==="text"){n.appendChild(document.createTextNode(r[i].data))}else{var o=document.createElement("span");var l=r[i].data;try{katex.render(l,o,{displayMode:r[i].display})}catch(f){if(!(f instanceof katex.ParseError)){throw f}console.error("KaTeX auto-render: Failed to parse `"+r[i].data+"` with ",f);n.appendChild(document.createTextNode(r[i].rawData));continue}n.appendChild(o)}}return n};var o=function(e,t,r){for(var n=0;n<e.childNodes.length;n++){var a=e.childNodes[n];if(a.nodeType===3){var l=i(a.textContent,t);n+=l.childNodes.length-1;e.replaceChild(l,a)}else if(a.nodeType===1){var f=r.indexOf(a.nodeName.toLowerCase())===-1;if(f){o(a,t,r)}}}};var l={delimiters:[{left:"$$",right:"$$",display:true},{left:"\\[",right:"\\]",display:true},{left:"\\(",right:"\\)",display:false}],ignoredTags:["script","noscript","style","textarea","pre","code"]};var f=function(e){var t;var r;for(var n=1,a=arguments.length;n<a;n++){t=arguments[n];for(r in t){if(Object.prototype.hasOwnProperty.call(t,r)){e[r]=t[r]}}}return e};var d=function(e,t){if(!e){throw new Error("No element provided to render")}t=f({},l,t);o(e,t.delimiters,t.ignoredTags)};t.exports=d},{"./splitAtDelimiters":2}],2:[function(e,t,r){var n=function(e,t,r){var n=r;var a=0;var i=e.length;while(n<t.length){var o=t[n];if(a<=0&&t.slice(n,n+i)===e){return n}else if(o==="\\"){n++}else if(o==="{"){a++}else if(o==="}"){a--}n++}return-1};var a=function(e,t,r,a){var i=[];for(var o=0;o<e.length;o++){if(e[o].type==="text"){var l=e[o].data;var f=true;var d=0;var s;s=l.indexOf(t);if(s!==-1){d=s;i.push({type:"text",data:l.slice(0,d)});f=false}while(true){if(f){s=l.indexOf(t,d);if(s===-1){break}i.push({type:"text",data:l.slice(d,s)});d=s}else{s=n(r,l,d+t.length);if(s===-1){break}i.push({type:"math",data:l.slice(d+t.length,s),rawData:l.slice(d,s+r.length),display:a});d=s+r.length}f=!f}i.push({type:"text",data:l.slice(d)})}else{i.push(e[o])}}return i};t.exports=a},{}]},{},[1])(1)});

2
katex/katex.min.css vendored

File diff suppressed because one or more lines are too long

9
katex/katex.min.js vendored

File diff suppressed because one or more lines are too long

212
main.css Normal file
View File

@ -0,0 +1,212 @@
body {
font: 16px/1.4 "proxima-nova", "Helvetica Neue", Arial, Helvetica, sans-serif;
}
.container {
margin: 0 auto;
margin: 0 auto;
width: 800px;
}
.header, .footer {
color: #fff;
background: #329894;
overflow: hidden;
}
.cta {
margin: 10px 0;
text-align: center;
}
.cta a {
border-radius: 3px;
display: inline-block;
font-weight: 600;
margin: 0 10px;
padding: 8px 24px;
text-decoration: none;
}
.header {
padding: 40px 0 0;
}
.logo {
color: #fff;
font-size: 45px;
margin: 0;
}
.tagline {
font-size: 28px;
font-weight: 300;
padding: 20px 0;
text-align: center;
}
.tagline em {
font-weight: 600;
}
.header .cta a {
border: 3px solid;
color: #fff;
}
.header .cta a:hover {
background: rgba(255, 255, 255, 0.1);
}
.demo {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
font-size: 22px;
margin: 50px 0 0;
}
.demo,
.demo-left,
.demo-right {
height: 260px;
}
.demo-left,
.demo-right {
box-sizing: border-box;
float: left;
padding: 20px 30px;
width: 50%;
}
.demo-instructions {
line-height: 1.5;
margin-bottom: 10px;
opacity: 0.8;
}
.demo-left {
background: #444;
}
.demo-left textarea {
background: #000;
border: none;
box-sizing: border-box;
color: #fff;
font: 14px Menlo, monospace;
height: 160px;
padding: 10px;
resize: none;
width: 100%;
}
.demo-right {
background: #fff;
color: #444;
}
#demo-output {
font-size: 18px;
padding: 10px 0;
overflow: auto;
}
.main {
background: #fff2e7;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
min-height: 400px;
position: relative;
padding: 30px 0;
}
.subtagline {
color: #329894;
font-size: 24px;
font-weight: 600;
padding: 20px 0;
text-align: center;
}
.features {
font-size: 20px;
margin: 0 auto;
width: 540px;
}
.features > li {
margin: 10px 0;
}
.main .examples {
margin: 40px 0;
}
.main .example {
font-size: 15px;
text-align: center;
margin: 30px 0;
}
.main .comparison-labels {
width: 100%;
height: 40px;
}
.main .comparison-labels .left,
.main .comparison-labels .right {
box-sizing: border-box;
width: 50%;
float: left;
height: 40px;
text-align: center;
font-size: 20px;
}
.main .comparison {
background-image: url(katex-comparison.gif);
background-position: 50% 50%;
background-size: cover;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
height: 340px;
width: 100%;
}
.main .cta {
padding-top: 50px;
}
.main .cta a {
border: 3px solid;
color: #329894;
}
.main .cta a:hover {
background: rgba(50, 152, 148, 0.1);
}
.footer {
padding: 30px 0;
font-size: 21px;
}
.ka-logo {
float: right;
}
.ka-logo img {
border: none;
vertical-align: -1px;
}
.credits {
float: left;
font-size: 16px;
}
.credits a {
color: white;
}
.errorMessage {
color: red;
}

32
main.js Normal file
View File

@ -0,0 +1,32 @@
window.startup = function() {
var tex = document.getElementsByClassName("tex");
Array.prototype.forEach.call(tex, function(el) {
katex.render(el.getAttribute("data-expr"), el);
});
var demoInput = document.getElementById("demo-input");
var demoOutput = document.getElementById("demo-output");
function doDemo() {
try {
katex.render(demoInput.value, demoOutput, {
displayMode: true
});
} catch(err) {
while(demoOutput.lastChild) {
demoOutput.removeChild(demoOutput.lastChild);
}
var msg = document.createTextNode(err.message);
var span = document.createElement("span");
span.appendChild(msg);
demoOutput.appendChild(span);
span.setAttribute("class", "errorMessage");
}
}
demoInput.addEventListener("input", function() {
doDemo();
});
doDemo();
};