Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dhowe/riscript
RiScript: a minor language
https://github.com/dhowe/riscript
creative-coding creative-writing generative-text natural-language-generation
Last synced: about 2 months ago
JSON representation
RiScript: a minor language
- Host: GitHub
- URL: https://github.com/dhowe/riscript
- Owner: dhowe
- License: gpl-3.0
- Created: 2023-11-08T05:16:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-14T10:44:23.000Z (10 months ago)
- Last Synced: 2024-04-26T02:22:12.523Z (8 months ago)
- Topics: creative-coding, creative-writing, generative-text, natural-language-generation
- Language: JavaScript
- Homepage: https://rednoise.org/rita/reference/riscript.html
- Size: 2.02 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/dhowe/riscript?label=code&color=yellow)
## RiScript: a scripting language for writers
RiScript is a minor language designed for writers working in computational media. It runs in a variety of environments, including the browser, Node, Observable, P5.js, Android and others. RiScript primitives (choices, symbols, gates, transforms, etc) can be used as part of any RiScript [grammar](https://rednoise.org/rita/reference/RiScript/grammar/) or executed directly using [evaluate()](https://rednoise.org/rita/reference/RiScript/grammar/). RiScript is free/libre/open-source and integrates with [RiTa](https://rednoise.org/rita).
For more documentation and examples see this interactive [notebook](https://observablehq.com/@dhowe/riscript) on observable.
### Installation
* For [esm](#an-esm-browser-sketch): ```import { RiScript } from "https://esm.sh/riscript";```
* For [browsers](#a-simple-browser-sketch): ``````
* For [node](#with-nodejs-and-npm): `$ npm install riscript`
```let { RiScript } = require('riscript');```
* For [developers](#developing)### Example
```javascript
import { RiScript } from "https://esm.sh/riscript";
let script = "[#name=[Jane | Bill]] was from [#place=[New York | Berlin]]."
+ " $name finds $place cold and wet in winter.";let result = RiScript.evaluate(script);
console.log(result);
```
## Developing
To install/build the library and run tests:
```sh$ git clone https://github.com/dhowe/riscript.git
$ cd riscript
$ npm install
$ npm run build
$ npm test```
If all goes well, you should see a list of successful tests and find the library built in 'dist'
Please make contributions via [fork-and-pull](https://reflectoring.io/github-fork-and-pull/) - thanks!
## About
* Author: [Daniel C. Howe](http://rednoise.org/daniel)
* Tutorial: [https://observablehq.com/@dhowe/riscript](https://observablehq.com/@dhowe/riscript)
* Github Repo: [https://github.com/dhowe/riscript](https://github.com/dhowe/riscript)
* Issues: [https://github.com/dhowe/riscript/issues](https://github.com/dhowe/riscript/issues)
* Reference: [https://rednoise.org/rita/reference](http://rednoise.org/rita/reference)
* RiTa Web: [https://rednoise.org/rita](http://rednoise.org/rita)
## Quick Start
#### A simple browser sketch
Create a new file on your desktop called 'test.html' with the following lines, save and drag it into a browser:```html
window.onload = function () {
let script = "[#name=[Jane | Bill]] was from [#place=[New York | Berlin | Shanghai]]."
+ " $name finds $place cold and wet in winter.";
let html = RiScript.evaluate(script);
document.getElementById("content").innerHTML = html;
};```
#### An ESM browser sketch
Create a new file on your desktop called 'test.html' with the following lines, save and drag it into a browser:```html
import { RiScript } from "https://esm.sh/riscript";
let script = "[#name=[Jane | Bill]] was from [#place=[New York | Berlin | Shanghai]]."
+ " $name finds $place cold and wet in winter.";
let html = RiScript.evaluate(script);document.getElementById("content").innerHTML = html;
```
#### With [p5.js](http://p5js.org/)
Create a new file on your desktop called 'test.html' with the following lines,, save and drag it into a browser:```html
function setup() {createCanvas(600,200);
background(245);
textAlign(CENTER)
textSize(18);let script = "[#name=[Jane | Bill]] was from [#place=[New York | Berlin | Shanghai]]."
+ " $name finds $place cold and wet in winter.";
let result = RiScript.evaluate(script);
text(result, 300, 100);createButton("refresh").mousePressed(() => location.reload());
}
```
#### With [node.js](http://nodejs.org/) and [npm](https://www.npmjs.com/)
To install: `$ npm install riscript````javascript
let { RiScript } = require('riscript');let script = "[#name=[Jane | Bill]] was from [#place=[New York | Berlin | Shanghai]]."
+ " $name finds $place cold and wet in winter.";let result = RiScript.evaluate(script);
console.log(result);
```
## Contributors
### Code Contributors
This project exists only because of the people who contribute. Thank you!