Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tiddly-gittly/zx-script
Run Javascript inside tiddlywiki like jupyter notebook
https://github.com/tiddly-gittly/zx-script
code-execution interactive ipython-notebook javascript jupyter-notebook literate-programming neteract playground tiddlywiki tiddlywiki5 tidgi zx
Last synced: about 1 month ago
JSON representation
Run Javascript inside tiddlywiki like jupyter notebook
- Host: GitHub
- URL: https://github.com/tiddly-gittly/zx-script
- Owner: tiddly-gittly
- License: mit
- Created: 2023-06-08T13:31:43.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-12-15T11:34:57.000Z (11 months ago)
- Last Synced: 2024-09-28T23:23:19.527Z (about 2 months ago)
- Topics: code-execution, interactive, ipython-notebook, javascript, jupyter-notebook, literate-programming, neteract, playground, tiddlywiki, tiddlywiki5, tidgi, zx
- Language: TypeScript
- Homepage: https://tiddly-gittly.github.io/zx-script/
- Size: 1.25 MB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: readme.tid
- License: LICENSE
Awesome Lists containing this project
README
title: $:/plugins/linonetwo/zx-script/readme
created: 20210915220048497
type: text/vnd.tiddlywiki!! Background
[[google/zx|https://github.com/google/zx]] is a tool for writing better scripts, with Javascript.
This tiddlywiki plugin enables you to run any tiddler with zx.
!! Basic Usage
!!! Prerequisit
This plugin requires [TidGi](https://github.com/tiddly-gittly/TidGi-Desktop) Desktop App environment to function properly. It will send tiddler content to the `zx` inside TidGi, and prints the output.
!!! Tiddler Type
Tiddler with title extension `*.js *.md *.mjs` can be execute without problem. Other tiddler witout extension (no `.xxx`) will be executed as `*.md` file, for example, tid file without extions will be executed as `*.md`, but it works without problem too, even you are writing wiki text instead of markdown.
If you add filetype `application/javascript` to your tiddler, it will be recognized as `*.mjs`.
!!! Button
A ViewToolbar button is added. You can click on it to execute the script inside your tiddler.
And the zx output will be printed below your tiddler content.
!!! Demo
```js
console.log(`!! Hi!`);
```See [[$:/plugins/linonetwo/zx-script/demo]] for demo of full tiddler execution.
!! Wiki Scripting
!!! Execute the code block on the $tw context
You can write some code that is surrounded with `/** tw */` separator. They will be recognized as js code and executed on the context that have access to the $tw api.
Global variables you can use:
* `$tw` try it in your [[developer tool|https://developer.mozilla.org/en-US/docs/Tools]] to play around!
* `_` [[lodash|https://lodash.com/docs/]]This means you can fetch some data on the zx script, and write the results to the wiki, creating new tiddlers.
!!! Access filter and macros
Filter function's call example is
```js
/** tw */
const result = $tw.wiki.filterOperators.sum((callback) => {callback({}, '2');callback({}, '2')})
console.log(result)
```!! Developer Documentation
See [[$:/plugins/linonetwo/zx-script/developer]]