Giter Club home page Giter Club logo

entangle's Introduction

Entangle

Another attempt at writing Tangle.js documents in markdown.

The main objective here was to keep the "explanation" part as readable as possible, without loosing the power of javascript.

Install

npm install -g entangle-doc

Usage

entangle <source.entangle>

If you have trouble opening the output html in Mac Safari, try Firefox.

Explanation

A "Entangle" document is split into three sections, separated by ---:

  1. the content (markdown)
  2. the config (yaml)
  3. the code (coffeescript)

The code is a single function, named update, that produces the dependent variables from the independent variables (i.e. the user controls). Entangle will bundle the content, script, and some styles (a la the original Tangle.js) into a standalone html file which you can open.

Example

example/cookies.entangle:

# Cookies

If you eat `${cookies} cookies`, you will consume `${calories} calories`, or `${percent}%` of your recommended daily intake.

---

cookies:
  class: TKAdjustableNumber
  min: 0
  max: 10
  initial: 3
percent:
  format: "%.0f"

---

update = ({cookies}) ->
  calories: cookies*50,
  percent: cookies*2.38

Running...

entangle example/cookies.entangle

... will output ...

example/cookies.html

API

I also included some hooks for parsing entangle code.

import {parse} from "entangle-doc"

const { html, javascript } = parse(source)

The resulting html is a div element you can put anywhere in the HTML body. The resulting javascript needs to be encapsulated in a <script> tag, but after that you can put it anywhere.

Similar projects

entangle's People

Contributors

rexgarland avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.