This is a simple "inline web renderer and interpreter" for Questmark.
It allows you to create "live" Questmark documents that you can easily work on and test in your browser!
- Save your Questmark document (in Markdown source code form!) as a
.html
file - Add the following lines to the bottom of the file, exactly as shown:
```comment <script src="https://unpkg.com/questmark-webrenderer@1.0.7/dist/webRender-basic.js"></script> <script src="https://unpkg.com/questmark-webrenderer@1.0.7/dist/main.js" type="module"></script> ```
- Open the .html file on your browser!
(see space-alien.md.html (demo) for an example)
You can also save your Questmark documents as .md
files, but then you need to open them using a webserver that forces the text/html
Content-Type header. local-web-server can do this using the following config file, for example:
module.exports = {
mime: {
'text/html': ['html', 'md']
}
}
and then run
npx local-web-server --config-file ws_config.js
Alternatively, you could load a .md file in your browser, open the browser console, and then paste and execute the following:
const qm_wr1 = document.createElement('script'); qm_wr1.setAttribute('src', 'https://unpkg.com/questmark-webrenderer@1.0.7/dist/webRender-basic.js');
const qm_wr2 = document.createElement('script'); qm_wr2.setAttribute('type', 'module'); qm_wr2.setAttribute('src', 'https://unpkg.com/questmark-webrenderer@1.0.7/dist/main.js');
document.body.appendChild(qm_wr1);
document.body.appendChild(qm_wr2);
You can currently customize the following things:
- Extra foreign functions can be supplied to the VM by setting the global variable
extraForeignFunctions
to a JavaScript object, with the keys mapping to foreign functions passed to the VM. See foreign-function.md.html (demo) for an example. - The VM can be modified prior to it starting, and can be prevented from auto-starting, by setting the global variable
preRun
to a function that receives thevm
instance. Returnfalse
from this function to prevent the VM from auto-starting. See prerun.md.html (demo).