Comments (10)
I have an implementation of text rendering for everything except OptionalSequence(). I'll be away for a few weeks, but I'll do that one when I'm back. Other than that, it renders everything in test.py
correctly, to my eyes at least. I've attempted to make the Unicode box-drawing character version look as much like the SVG version as possible. The pure-ASCII version, well, ain't know way that's gonna look that nice :-)
My changes do not affect any existing code - they are 100% new routines and a single new class.
Here are samples:
test_svg.html
- The SVG versions of all the test cases.test_unicode.html
- Same stuff, drawn in character-cell graphics, using the Unicode 25xx box-drawing characters.test_ascii.html
- Same stuff, drawn with pure ASCII characters. This is the reason I'm doing the work, but it ain't pretty :-)
Feel free to comment on these results. I'll be back online in a couple of weeks, and I'll get back to finishing this work.
from railroad-diagrams.
I've thought about this before, too, and it's certainly possible, but it would involve essentially rewriting the entirety of the rendering functions. On the plus side, all the essential rendering logic has already been written once, so it should be relatively straightforward to translate over, but it's definitely a Task.
If you're interested in trying it out, you probably want the nice box-drawing characters
from railroad-diagrams.
Well I'm playing with the idea of using kitty image protocol in terminals to render the SVG graphics.
WDYT about a lua version of railroad-diagrams? That would ease integration with neovim (or any other lua host), regarding which I found this: https://gist.github.com/brimworks/1390733
from railroad-diagrams.
I can't actively maintain a Lua version, so I'm not comfortable keeping such code in this repo, but I'm more than happy to link to a well-done port.
from railroad-diagrams.
FWIW, I built a railroad diagram text renderer for a mainframe-based tool ("B2H") about 20 years ago, in IBM's Rexx language. The tool took IBM's BookMaster GML markup as input, so the syntax is different from this package's, but the data model is almost identical. I have a need for text output myself, so I'm going to take a crack at re-writing my old work in Python as something like a set of writeText()
and formatText()
methods for this package's classes.
from railroad-diagrams.
Oh dang, that's neat! Having both renderers is nice - the box-drawing characters look real messed up given the fonts on my machine right now, but they look great in the console; the ASCII looks decent in both.
from railroad-diagrams.
Having both renderers is nice
It's actually just a single renderer, which takes a dict
parameter that applies a character for each use. And the renderer has a method to modify or wholly replace the dict. So if, for example, you're using a font that has better rounded box corners, you can use them instead of the Unicode curved corners.
from railroad-diagrams.
Forgot to say - this is in Python right now. If a PR is welcome for this work, I'll translate it to Javascript as well.
from railroad-diagrams.
Definitely welcome. I'd also be happy to do the port myself, if you're more comfortable with Python. But if you're fine with JS as well, go ahead.
from railroad-diagrams.
I've implemented the last of the diagram classes, and updated the test result files (see above). I'll start putting a PR together for the Python port.
from railroad-diagrams.
Related Issues (20)
- sdist is missing tests
- No __repr__ for Python Group() or HorizontalChoice() HOT 1
- Flake8 config errors due to wrong comment style
- Fix Choice down spacing HOT 3
- Diagram.addTo() doesn't find the right <script> tag for <script type=module>
- Add an expectation container HOT 3
- Snyk XSS vulnerability HOT 1
- Missing files in sdist HOT 1
- Options to colour the Terminals? HOT 2
- suggestion: typescript support HOT 1
- Python port leaves gap after OptionalSequence HOT 2
- railroad-diagrams.js is missing Group() HOT 1
- Bug in AlternatingSequence exception HOT 1
- Please create git tags for releases HOT 9
- Give the dingus the ability to set the global options HOT 6
- unexpected behaviour using Stack() HOT 2
- example.html has bit-rotted HOT 3
- Changelog? HOT 3
- RELEASE NOTES HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from railroad-diagrams.