Successor of the flowchart-fun syntax. Store tabular data and graph information in the same document.

Overview

graph-selector-syntax

Version Coverage License Build

A syntax for storing graphs and tabular data in plain text

View Examples

Installation

npm install graph-selector

Usage

import { parse } from "graph-selector";

const graph = parse(`
  #a.class1.class2[attr=value] node label
   edge label: #b.class1[attr=value] another label
`);

const { nodes, edges } = graph;

console.log(nodes, edges);

Overview

For context, I'm experimenting with this language to determine if it should become the successor to the current flowchart-fun language. I wrote a blog post explaining my thought process.

What does this syntax look like?

  • indentation to create edges
  • edge labels before a colon :
  • css-selector-ish-looking supplementary data for nodes
  • point to nodes/edges using parentheses (ref by label) (#ref-by-id) (.ref-by-class)
#a.class1.class2[attr=value] node label
 edge label: #b.class1[attr=value] another label

What does the parser output look like?

  • kept as flat as possible
  • everything parses to strings for now (no numbers, no booleans)
/* output from example above */
{
  "nodes": [
    {
      "lineNumber": 1,
      "label": "node label",
      "id": "a",
      "classes": ".class1.class2",
      "attr": "value"
    },
    {
      "lineNumber": 2,
      "label": "another label",
      "id": "b",
      "classes": ".class1",
      "attr": "value"
    }
  ],
  "edges": [
    {
      "id": "a-b-1",
      "lineNumber": 2,
      "source": "a",
      "target": "b",
      "label": "edge label"
    }
  ]
}

Developing

This is a monorepo containing a /parser (written in TS) and a website of /examples illustrating how you can use it.

Git clone, then install dependencies with pnpm install. Then you can start both the parser and the examples websites with pnpm dev.

Debugging Tests

In VS Code, debugging tests can be done by selecting Javascript Debug Terminal from the command palette. Then you can run pnpm test:watch to run the tests in debug mode and stop on breakpoints. (Leaving this here because I haven't been able to make it work any other way.)

Next Steps

  • add benchmarks
  • add syntax highlighter that can be used with Monaco; eventually for CodeMirror as well

Contributing

The goal of this project was to improve upon and separately-publish the parser used in Flowchart Fun. I want to make it more robust and more flexible. I also want to make it accessible to other projects.

I'm very open to contributions! Specifically in the following ways...

Contributing to the Conversation

I'm really interested in feedback on the syntax and how it can be improved. Join the conversation via Github discussions or by opening an issue. Some open problems I'm interested in solving:

  1. Automatic ID's by position vs. by label
  2. Indenting below pointers

I realize this is a bit vague. I intend to write a blog post explaining these problems and their inherent tradeoffs soon!

Contributing an Example

Examples show how this syntax and parser can be used to render different types of graphs using a variety of libraries, including D3, Cytoscape JS, and Recharts.

Add an example by first adding a route to examples/src/Router.tsx and then adding a page examples/src/pages. If your example uses a different renderer, you'll need to set the type property in the route, and then add that type to the side bar in examples/src/App.tsx.

You might also like...

The Covid-19 data-app collects information from API and present data for the novel coronavirus.

The Covid-19 data-app collects information from API and present data for the novel coronavirus.

COVID-19-data-app This project was bootstrapped with Create React App. The Covid-19 data-app collects information from API and present data for the no

Jun 23, 2022

Diagram-maker - A library to display an interactive editor for any graph-like data.

Diagram-maker - A library to display an interactive editor for any graph-like data.

Diagram Maker Diagram Maker is a library to display an interactive editor for any graph-like data. Following is a screenshot from one of the consumers

Dec 27, 2022

Fun way to share some of your (already) public StackOverflow user data to the internet.

Fun way to share some of your (already) public StackOverflow user data to the internet.

ProfileOverflow A simple app leveraging StackExchange APIs to show some StackOverflow accounts information. Made for fun during a weekend as practice.

Sep 14, 2022

A simple To-do app project made using JavaScript ES6 and Webpack - Microverse. You can add, remove, check tasks, and remove all the tasks that were done at the same time. Feel free to see the live version, if you like it please give it a star!

To Do List a to do list javascript app buit using webpack and es6. Built With HTML CSS JavaScript Wepack Live Demo (if available) Live Demo Link Getti

Dec 17, 2022

The ToDoList app let you create a task, added to a list of task, mark it as complete, and delete individual or multiple tasks at the same time

The ToDoList app let you create a task, added to a list of task, mark it as complete, and delete individual or multiple tasks at the same time. The app manipulate the Local-Storag so you can save your tasks there. Built with HTML, CSS and JavaScript. First practice using Webpack, Modules and tests with Jest

Jul 21, 2022

Autocompletion, in-code secret peeking 🔎, syncing, and more, for your .env files in VSCode. 👑 From the same people who pioneered dotenv.

Autocompletion, in-code secret peeking 🔎, syncing, and more, for your .env files in VSCode. 👑 From the same people who pioneered dotenv.

Dotenv Official (with Vault) for VSCode Official Dotenv. Syntax highlighting, autocompletion, in-code secret peeking, and .env file syncing with Doten

Dec 19, 2022

The world's fastest game! User gets ten dice. Then rolls and rolls as fast as they can until he gets all their dice on the same number.

tenzies-game The world's fastest game! User gets ten dice. Then rolls and rolls as fast as they can until he gets all their dice on the same number. I

Nov 26, 2022

A simple in-memory key-value cache for function execution, allowing both sync and async operations using the same methods

A simple in-memory key-value cache for function execution, allowing both sync and async operations using the same methods. It provides an invalidation mechanism based both on exact string and regex.

Dec 15, 2022
Comments
  • add lint staged

    add lint staged

    • chore(lint): add lint-staged
    • chore(lint): update pre-commit hook
    • chore(lint): save bad formatted file, expect fix
    • chore(lint): add a fallible lint to ci
    opened by rob-gordon 2
  • Allow Single Node or Pointer

    Allow Single Node or Pointer

    Right now we permissively allow multiple pointers and/or a node on each indented line. My gut tells me that will create more ambiguity than it will utility so I'm going to remove that. A line will only be allowed one node or one pointer.

    opened by rob-gordon 0
  • Ambiguous indent

    Ambiguous indent

    Ambiguous indent

    https://user-images.githubusercontent.com/159949/204559546-a9b2e335-014d-43e7-8a8e-4f94b49b29cb.mov

    Expected result Indenting should move edge to be from b->c or from both pointers to c

    opened by rob-gordon 0
Card IDE (CIDEr) - Design game cards using HTML/Handlebars, CSS, and tabular data

CIDEr Card IDE (CIDEr) - Design game cards using HTML/Handlebars, CSS, and tabular data. Website: Start using Cider About CIDEr Cider was created to f

Oatear 37 Dec 10, 2022
Generate deterministic fake values: The same input will always generate the same fake-output.

import { copycat } from '@snaplet/copycat' copycat.email('foo') // => '[email protected]' copycat.email('bar') // => 'Thurman.Schowalter668@

Snaplet 201 Dec 30, 2022
Alpha version of ALBot 2.0, the spiritual successor to ALBot

ALBot 2.0 Alpha Alpha version of ALBot 2.0, the spiritual successor to ALBot. ALBot 2.0 uses Discord.js to interface with the Discord API, supplanting

UF Open Source Club 8 Nov 17, 2022
A home for modern admin UIs; successor to Torque

Forque A home for admin apps Meta State: development Staging: https://tools-staging.artsy.net Kubernetes Production: https://tools.artsy.net Kubernete

Artsy 8 Sep 13, 2022
Demo showcasing information leaks resulting from an IndexedDB same-origin policy violation in WebKit.

Safari 15 IndexedDB Leaks Description This demo showcases information leaks resulting from an IndexedDB same-origin policy violation in WebKit (a brow

FingerprintJS 101 Nov 5, 2022
The Main Purpose The main purpose of creating an anaonline information system, as an effort responsive to the management of the data of the Members of the Persis Youth based on information technology systems

landing-page-pp landing-page-pp.vercel.app #The Main Purpose The main purpose of creating an anaonline information system, as an effort responsive to

Hilman Firdaus 6 Oct 21, 2022
It shows an effective way to correct bus arrival information using data analytics based on Amazon Serverless such as Kiness Data Stream, Kinesis Data Firehose, S3, and Lambda.

Amazon Serverless를 이용한 실시간 버스 정보 수집 및 저장 본 github repository는 버스 정보를 주기적으로 수집하여 분석할 수 있도록, Amazon Serverless인 Amazon Kinesis Data Stream, Kinesis Data

John Park 4 Nov 13, 2022
Random Fractals stash of Observable Data Tools 🛠️ and Notebooks 📚 in ES Modules .js, .nb.json, .ojs, .omd, .html and .qmd document formats for Data Previews

Random Fractals stash of Observable Data Tools ??️ and Notebooks ?? in ES Modules .js, .nb.json, .ojs, .omd, .html and .qmd document formats for Data Previews in a browser and in VSCode IDE with Observable JS extension, Quarto extension, and new Quarto publishing tools.

Taras Novak 14 Nov 25, 2022
🍺 A public REST API for retrieving information about Systembolaget's products, and which products that are available in which store

?? systembolaget-api A public REST API for retrieving information about Systembolaget's products, and which products that are available in which store

Daniel Cronqvist 9 Nov 22, 2022