Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The point of this pull request is to make a system where everyone can control the rendered note. Presently I'm forcing asciinema and mathjax down users' throats, maybe someone doesn't want these.
Introducing the plugin system
A plugin is an anonymous function that takes the note of a body (string), and the note (object) and must return a promise of HTML (string). For example, here's the code for the markdown plugin:
It makes use of
loadScript(name, url)
common function which returns a promise which will get resolved right after loading the script at the provided URL.A plugin should be registered in the repository located in
resources/note-format/repository.json
under the format:Here's how to use the plugin manager:
will list the installed plugins in order of execution.
will list all the plugins in the repository.
will install the markdown and asciinema plugins after the second plugin.
will remove the third plugin. Unfortunately it does not support multiple indeces, unlike the install rule.
will produce the output javascript file.
What it actually does
It generates a file in
resources/note-format/note-format.out.js
which is an array of the formatters to be applied in order.bundle-js should be executed after every compilation
Available formatters
markdown
Will load Showdown and render the body to HTML.
mathjax
Will load MathJax and will render equations.
asciinema
Will replace all instances of
$asciinema(attachement-name.cast)
with an asciinema playeriframe
Will set a sandbox around all iframes. The set value is "allow-scripts allow-same-origin allow-forms"
js-eval
Evaluates all the javascript code that starts with
!eval
on its first line. The output is displayed inside a sandboxed iframe with onlyallow-scripts
. For example if the note contains the code:Then this javascript is executed in an iframe that will show "hello world!" 10 times, each on a line.