probmods / webppl-editor

Browser-based editor for WebPPL
Other
8 stars 1 forks source link
editor webppl

A browser-based code editor for WebPPL (requires version 0.9.0 or higher)

Demo: https://probmods.github.io/webppl-editor

Usage:

<html>
<head>
<meta charset="UTF-8"> <!-- tell the browser that editor.js contains unicode -->
<script src="https://github.com/probmods/webppl-editor/raw/master/webppl.js"></script> <!-- compiled webppl library; get this from https://github.com/probmods/webppl -->
<script src="https://github.com/probmods/webppl-editor/raw/master/webppl-editor.js"></script>
<link rel="stylesheet" href="https://github.com/probmods/webppl-editor/blob/master/webppl-editor.css">
</head>
<body>
...
</body>
<script>
// find all <pre> elements and set up the editor on them
var preEls = Array.prototype.slice.call(document.querySelectorAll("pre"));
preEls.map(function(el) { editor.setup(el, {language: 'webppl'}); });
</script>
</html>

webppl-editor installs these functions in the global namespace:

We also ship the editor as editor.ReactComponent.

Development:

grunt browserify # makes webppl-editor.js
grunt css        # makes webppl-editor.css
grunt uglify     # makes webppl-editor.min.js
grunt bundle     # = browserify + css
grunt watch-js   # reruns browserify when it detects file changes
grunt watch-css  # reruns css when it detects file changes