Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol aliases, for ASCII art #68

Open
edemaine opened this issue May 12, 2022 · 0 comments
Open

Symbol aliases, for ASCII art #68

edemaine opened this issue May 12, 2022 · 0 comments

Comments

@edemaine
Copy link
Owner

edemaine commented May 12, 2022

The general idea is to support aliases between symbols, which is helpful especially for ASCII art, as an alternative to using spreadsheets.

Aliases in mapping files

Here's something we could support in the .txt mapping format without ambiguity (as a symbol currently can't meaningfully start with =, unless that's the start of a terrible filename):

o <circle r="5"/>
O = o
0 = o

In JavaScript/CoffeeScript, we could plausibly return the string "= o" as shorthand to say "use this other symbol". Or maybe a helper function, like this.replaceSelf('o') or this.lookupSymbol('o').

Use in ASCII art

Why is this useful? It lets you define long symbols like locking 2-toggle, rotated 90, flipped and then use them in ASCII art by defining a local alias like A = locking 2-toggle, rotated 90, flipped, and then draw:

  |
--A--
  |

Command-line support: brackets

If drawing.txt has the aliases for the ASCII drawing drawing.asc, I could see using this on the command line like so:

svgtiler symbols.coffee drawing.txt drawing.asc

To do multiple files on the same command line, it'd be nice to have bracket support to easily forget mappings:

svgtiler symbols.coffee \( drawing1.txt drawing1.asc \) \( drawing2.txt drawing2.asc \)

It'd still be hard to do things like *.txt *.asc though...

Combining mapping and drawing files?

In general I feel like we want these aliases to be local to an ASCII art file, so can we figure out a mechanism to include both ASCII art and symbol aliases/definitions in the same file? Something like:

A = locking 2-toggle, rotated 90, flipped
---
  |
--A--
  |

Here I'm using the YAML --- syntax for separating directives from document, but I don't think it's the right notation here, as it looks like ASCII art.

More generally, perhaps we could have a general mechanism for a "driver" file that contains and/or includes multiple files for SVG Tiler. Perhaps a .multi extension? For example:

=== aliases.txt
A = locking 2-toggle, rotated 90, flipped
=== drawing.asc
  |
--A--
  |
=== aliases.txt
A = locking 2-toggle, rotated 180
=== repeat: drawing.asc

Alternatively, we could use ^A to prefix filenames; see #102.

Or even more of a driver file would be just to specify the command-line arguments in a file (instead of a Makefile): This already got implemented in #99.

-p
drawing1.txt   # aliases for drawing1
drawing1.asc
drawing2.txt   # aliases for drawing2
drawing2.asc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant