katef / kgt

BNF wrangling and railroad diagrams
BSD 2-Clause "Simplified" License
593 stars 30 forks source link

Text output for Model 33 ASR teletypes #65

Open cabo opened 1 year ago

cabo commented 1 year ago

When writing RFCs, we are limited to 69 columns (72 columns in an emergency) for plaintext output (SVG for HTML and PDF are unrestricted).

I can easily squash 4 columns by removing the indentation for the diagram:

cri-reference:
    ╭──────────────────────────────────────>───────────────────────────────────────╮
    │                                                                              │
    │                               ╭─────────────────────>─────────────────────╮  │
    │                               │                                           │  │
    │                               │          ╭──────────────>──────────────╮  │  │
    │                               │          │                             │  │  │
    │                               │          │           ╭──────>───────╮  │  │  │
    │                               │          │           │              │  │  │  │
│├──╯──╮── scheme ── authority ──╭──╯── path ──╯── query ──╯── fragment ──╰──╰──╰──╰──┤│
       │                         │
       ╰──────── discard ────────╯

The ideal way to handle this would be to be able to give a column limit to rrtext/rrutf8 and let kgt figure it out...

A simple space-saving flag (e.g., remove spaces around scheme, authority..., making │├── and ──┤│ vertical) would already help.

katef commented 1 year ago

Aha. I actually want this feature for responsive HTML output too. It'd be the same mechanism; target a particular width (and in the case of HTML, render out for various widths and select between them with a media query).

I did some coding for this, I have WIP stuff that I haven't finished off and pushed upstream.

cabo commented 1 year ago

Looking forward to seeing some of this!