document.getElementById("run").onclick = function(){
Bedstead({
arguments: document.getElementById("input").value.split(" "),
- print: function(text) {
- document.getElementById("output").textContent = text;
+ print: function(charstring) {
+ document.getElementById("output").textContent = charstring;
+ document.getElementById("rendered")
+ .setAttribute("d", charstring
+ .replaceAll(/<!--(?:[^-]|-[^-])*-->/g, "")
+ .replace(/^.* [hv]stem /, "")
+ .replace(/^/, "m ")
+ .replaceAll(/ rmoveto/g, "")
+ .replaceAll(/ rlineto/g, "m")
+ .replace(/ endchar/, ""));
}
});
};
<input type="button" id="run" value="Run!"/>
</form>
<p><code id="output"></code></p>
+ <div>
+ <svg width="600" height="1000" xmlns="http://www.w3.org/2000/svg">
+ <path id="rendered" fill="currentColor"/>
+ </svg>
+ </div>
</body>
</html>