5 ms·
The way I use ASCII art diagrams in my source-code is through this simple web service that I hosted: https://dot-to-ascii.ggerganov.com https://dot-to-ascii.gg
by ggerganov 4y ago
The way I use ASCII art diagrams in my source-code is through this simple web service that I hosted:
https://dot-to-ascii.ggerganov.com https://dot-to-ascii.ggerganov.com
I generate the ASCII graph and then paste it in the comments together with a link to the service. This way I can go back later and update it if needed:
/*
Link: https://dot-to-ascii.ggerganov.com/?src_hash=476410d3 https://dot-to-ascii.ggerganov.com/?src_hash=476410d3
0.6
┌─────────────────────────┐
▼ │
┌───┐ 0.8 ┌───┐ 0.1 ┌───┐ 0.7 ┌───┐ 0.2 ┌───┐
│ d │ ─────▶ │ │ ◀───── │ e │ ─────▶ │ a │ ─────▶ │ b │
└───┘ │ c │ └───┘ └───┘ └───┘
│ │ 0.4 │
│ │ ◀──────────────────────────────────┘
└───┘
*/
- sph 4y agoFor some reason the arrow ▶ is a double-width character on my PC so it breaks. I'm using Noto Sans Mono as monospace font. Broken with Iosevka as well, works with Dejavu Sans Mono. That said, it's pretty cool, bookmarked. EDIT: weird now I'm looking at my comment from an iPhone and the arrow is rendered with the arrow emoji. Have I found an exploit to embed emojis in HN comments?!
- deleted 4y ago[deleted]
- ggerganov 4y agoThere is a "Boxart" button at the bottom of the page to toggle between pure ASCII chars and "extended" ASCII (not sure what is the proper name).
- lovelymono 4y ago> EDIT: weird now I'm looking at my comment from an iPhone and the arrow is rendered with the arrow emoji. Have I found an exploit to embed emojis in HN comments?! Apple emoji font, in addition to emojis, also includes other characters like numbers, arrows, and "trademark" (tm), "registered" (r), and "copyright" (c) symbols, so that's why.
- chrismorgan 4y ago▶ is not a box-drawing character like the rest, so most monospace fonts won’t support it, so it’ll be rendered in a different font with almost certainly different metrics, so in environments that follow text metrics rather than rigidly drawing on a grid, that arrow will ruin everything. The web is one such environment.
- ziml77 4y agoInterestingly, my browser's default monospace choice of Courier is only very slightly distorted by the arrowheads. Like at most 2 pixels off when looking at it at whatever size it is on the dot-to-ascii site. Switching to Menlo results in no distortion at all.
- behnamoh 4y agoYou should try fonts that are not proportional.
- bloopernova 4y agoWow this is wonderful, I hope to use this a lot!
- zero_shift 4y agoThis is great! Thanks for sharing, it's added to my bookmarks