Show HN: Box of Rain - Auto-Layouted ASCII Diagrams

(github.com)

24 points | by switz 5 days ago ago

14 comments

  • latchkey 5 days ago ago

    Neat, but you can just do this in mermaid too. Taking one of your examples:

      <mermaid>
      flowchart LR
    
      web([Frontend])
    
      subgraph platform [Cloud Platform]
        api([API Server])
        db[(Database)]
        api --> db
      end
    
      web -->|HTTPS| api
      </mermaid>
    
    If you install the latest https://oj-hn.com , you can see it rendered inline here.
    • switz 5 days ago ago

      Fair point. I added basic mermaid parsing to the library so you can do that here too.

          $ echo 'flowchart LR
              web([Frontend])
              subgraph platform [Cloud Platform]
                api([API Server])
                db[(Database)]
                api --> db
              end
              web -->|HTTPS| api' | npx box-of-rain --mermaid
      
                                 ╔══ Cloud Platform ════════════════════╗
                                 ║                                      ║
          ╭──────────╮           ║  ╭────────────╮      ╔════════════╗  ║
          │          │           ║  │            │      ║            ║  ║
          │ Frontend │ ─── HTTPS ──▶│ API Server │ ────▶║  Database  ║  ║
          │          │           ║  │            │      ║            ║  ║
          ╰──────────╯           ║  ╰────────────╯      ╚════════════╝  ║
                                 ╚══════════════════════════════════════╝
      • latchkey a day ago ago

        Nice work! Love it.

  • josefdlange a day ago ago

    I'm just here for the Grateful Dead reference.

    • SoleilAbsolu 13 hours ago ago

      If this runs on the CLI, the system prompt should be "What do you want me to do?"

    • josefdlange a day ago ago

      Holy moly -- you're behind Relisten, OP? I owe you a great debt of gratitude for the hours of musical joy Relisten has given me.

      • switz a day ago ago

        Yup! We’re just one link in the chain (bands, tapers, archivists, & the listeners), but I appreciate the sentiment. Alec and I have been running Relisten for over a decade and we’ve put a lot of work into it these past few years.

        Had to give the Dead a little nod here

        • josefdlange a day ago ago

          Too true! Feels extra nice to be able to spread the sentiment of gratitude so far and wide. Keep it up!

  • Retr0id 2 days ago ago

    On my system the "right arrow" glyph is 2 units wide and breaks all the layouts.

    • switz 2 days ago ago

      TIL about ambiguous width unicode characters. Turns out some locales render these chars as double width. I'm attempting to work out a solution.

      Seems like maybe there are some universal half-width characters that can be used.

      https://www.unicode.org/reports/tr11/

      • exceptione a day ago ago

        Weird. Same issue with NL-locale @ firefox, while terminal is ok. So it is not confined to East-Asian locales if that is what you think.

      • Retr0id a day ago ago

        Unfortunately even if you pick nominally-equal-width glyphs, on the web you can still get screwed over by font substitution/fallback done by the browser.

    • OhMeadhbh 2 days ago ago

      First off, let me say it is awesome you're doing something like this.

      But... I'm encountering a similar issue on both Chrome and Firefox on Leenucks. I guess it's possible you don't see the problem on your Mac because both these browsers use the OS to do font rendering.

    • Surac a day ago ago

      same in my Brave Browser, why not stick to nomal Ascii?