Skip to content

Instantly share code, notes, and snippets.

@qoh
Created April 15, 2016 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qoh/bb51a81e8be7720371282c98d5f127e2 to your computer and use it in GitHub Desktop.
Save qoh/bb51a81e8be7720371282c98d5f127e2 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>LaTeX Editor</title>
<style>
* {
box-sizing: border-box;
}
body {
margin: 0;
}
html, body, #container {
height: 100%;
}
#container { display: flex; }
#container > * { flex: 1; }
#source {
padding: 8px;
overflow-y: scroll;
resize: none;
border: none;
background: #111;
color: #ccc;
font-family: "Source Code Pro", monospace;
font-size: 14px;
}
#source:focus { outline: none; }
#output { background: white; }
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Code+Pro&subset=latin,latin-ext">
</head>
<body>
<div id="container">
<textarea id="source" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></textarea>
<div id="output"></div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.5.1/katex.min.js"></script>
<script>
(function() {
"use strict";
var source = document.getElementById("source");
var output = document.getElementById("output");
source.addEventListener("input", function(e) {
try {
katex.render(source.value, output, {
displayMode: true,
throwOnError: false
});
} catch (error) {
output.textContent = error.message;
}
});
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment