5390fa62ede7

More
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Wed, 25 Oct 2023 22:46:40 -0400
parents 96273ff110b3
children 05ef9c8cbeeb
branches/tags (none)
files bin/boxify bin/watch-latex

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/boxify	Wed Oct 25 22:46:40 2023 -0400
@@ -0,0 +1,42 @@
+#!/usr/bin/env python3
+
+import sys
+
+lines = sys.stdin.readlines()
+
+def ch(row, col):
+    if row < 0 or row >= len(lines):
+        return None
+    line = lines[row]
+    if col < 0 or col >= len(line):
+        return None
+    return line[col]
+
+for row, line in enumerate(lines):
+    for col, char in enumerate(line):
+        c = char
+        if char == '-':
+            c = '—'
+        elif char == '|':
+            c = '│'
+        elif char == '+':
+            u = ch(row-1, col) == '|'
+            d = ch(row+1, col) == '|'
+            l = ch(row, col-1) == '-'
+            r = ch(row, col+1) == '-'
+            if u and d and l and r: c = '┼'
+            elif u and d and l and not r: c = '┤'
+            elif u and d and not l and r: c = '├'
+            elif u and not d and l and r: c = '┴'
+            elif not u and d and l and r: c = '┬'
+            elif u and r: c = '└'
+            elif u and l: c = '┘'
+            elif d and l: c = '┐'
+            elif d and r: c = '┌'
+            elif u and d: c = '│'
+            elif l and r: c = '─'
+            else:
+                print(u, d, l, r,)
+                assert False
+
+        sys.stdout.write(c)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/watch-latex	Wed Oct 25 22:46:40 2023 -0400
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+NAME="$1"
+shift
+
+echo "$NAME".tex "$@" | peat "mklatex $NAME"