• Stars
    star
    1,561
  • Rank 29,781 (Top 0.6 %)
  • Language
    Python
  • License
    MIT License
  • Created about 12 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿš‚ A small JS+SVG library for drawing railroad syntax diagrams, like on JSON.org. Now with a Python port!

Railroad-diagram Generator

Diagram(Stack('Generate', 'some'), OneOrMore(NonTerminal('railroad diagrams'), Comment('and more')))

This is a small library for generating railroad diagrams (like what JSON.org uses) using SVG, with both JS and Python ports.

Railroad diagrams are a way of visually representing a grammar in a form that is more readable than using regular expressions or BNF. They can easily represent any context-free grammar, and some more powerful grammars. There are several railroad-diagram generators out there, but none of them had the visual appeal I wanted, so I wrote my own.

Here's an online dingus for you to play with and get SVG code from!

Versions

This library is supported both as a JS module and a Python module, and the install and use instructions for each are in their lang-specific READMEs.

Caveats

SVG can't actually respond to the sizes of content; in particular, there's no way to make SVG adjust sizing/positioning based on the length of some text. Instead, I guess at some font metrics, which mostly work as long as you're using a fairly standard monospace font. This works pretty well, but long text inside of a construct might eventually overflow the construct.

License

Standard MIT license; see LICENSE.

Don't ask me for permission to use any part of this project, just use it. I would appreciate attribution, but that is not required by the license. If you're doing something cool with it, again I'd appreciate it if you let me know, but that's not required either.

More Repositories

1

parse-css

๐Ÿ‡ Standards-based CSS Parser
JavaScript
328
star
2

specs

๐Ÿ“ Spec proposals that aren't yet approved by the relevant Working Group.
HTML
176
star
3

wordle-list

List of possible wordle words
138
star
4

recipe-db

Database of recipes used by http://xanthir.com/recipes/
37
star
5

password

๐Ÿ™ˆ A password hasher, for the generation of passwords.
HTML
29
star
6

css-toggle

Proposal for a CSS Toggle spec
HTML
28
star
7

Markdown

โฌ‡๏ธ A state-machine-based Markdown parser.
PHP
28
star
8

symbols

https://tabatkins.github.io/symbols Easy access to commonly-needed symbols that aren't on your keyboard.
HTML
23
star
9

depixel

๐ŸŽ‡Depixelating Pixel Art
15
star
10

bignum

๐Ÿ”Ÿ JS Bignum classes
JavaScript
12
star
11

roll

๐ŸŽฒ An exact-results dice-rolling library, for answering dice-related stat questions.
JavaScript
10
star
12

kdlpy

Handwritten KDL parser in Python 3
Python
9
star
13

JSONDB

A JSON datastore in PHP
PHP
6
star
14

sublime-tweets

A syntax file for Sublime Text that helps you edit tweets, by checking tweet length for you.
6
star
15

katex

Python port of the KaTeX math rendering library
JavaScript
4
star
16

highlighter

A self-contained *markup-preserving* syntax highlighter, powered by Pygments. Usable from command-line or as a Python module.
Python
4
star
17

proposal-call-this-operator

TC39 Proposal for a "call" operator, moving `fn.call()` to `fn::()`
3
star
18

proposal-dom-el

Proposal for a better element-creation API
3
star
19

life

My Life, as managed by Git
1
star
20

cssmath

โŠ•โŠ–โŠ—โŠ˜ Testing ground for a template-tag-based DSL for CSS math
1
star
21

tabatkins.github.io

HTML
1
star
22

animal-diet

Personal project for managing animal diet sheets.
HTML
1
star
23

bikeshed-tests

All the Bikeshed you can eat!
Python
1
star
24

proposal-local-font-access

Proposal for a way to access local fonts to a page in a privacy-preserving way, and cache them to the rest of the origin.
1
star
25

flippintables

Trivial Twitter API script that runs the FlippinTables account
PHP
1
star
26

unbias

HTML
1
star