# JSCPP - Template --{{0}}-- This document defines some basic macros for applying the JavaScript C++ interpreter [JSCPP](https://felixhao28.github.io/JSCPP) in [LiaScript](https://LiaScript.github.io) to make Markdown code-blocks executable. __Try it on LiaScript:__ ![demo](demo.gif) https://liascript.github.io/course/?https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md __See the project on Github:__ https://github.com/liaTemplates/JSCPP --{{1}}-- There are three ways to use this template. The easiest way is to use the `import` statement and the url of the raw text-file of the master branch or any other branch or version. But you can also copy the required functionionality directly into the header of your Markdown document, see therefor the [last slide](#4). And of course, you could also clone this project and change it, as you wish. {{1}} 1. Load the macros via `import: https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md` 2. Copy the definitions into your Project 3. Clone this repository on GitHub ## `@JSCPP.eval` --{{0}}-- Add the macro `@JSCPP.eval` to the end a single C++ code-block to make it executable and editable in LiaScript. The current code gets evaluate by the JSCPP interpreter and the result is shown in a console below. ``` c #include using namespace std; int main() { int a = 12; int rslt = 0; for(int i=1; i { output += s }}}); output; } catch (msg) { var error = new LiaError(msg, 1); try { var log = msg.match(/(.*)\nline (\d+) \(column (\d+)\):.*\n.*\n(.*)/); var info = log[1] + " " + log[4]; if (info.length > 80) info = info.substring(0,76) + "..." error.add_detail(0, info, "error", log[2]-1, log[3]); } catch(e) {} throw error; } @end ``` --{{1}}-- If you want to minimize loading effort in your LiaScript project, you can also copy this code and paste it into your main comment header, see the code in the raw file of this document. {{1}} https://raw.githubusercontent.com/liaTemplates/JSCPP/master/README.md