Download _work/float-layout/probe_typ.py from m-rui001/math-tex2typst: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/datasets/m-rui001/math-tex2typst/resolve/main/_work/float-layout/probe_typ.py
- Command line
-
hf download hf://datasets/m-rui001/math-tex2typst/_work/float-layout/probe_typ.py
-
curl -L -o probe_typ.py https://huggingface.co/datasets/m-rui001/math-tex2typst/resolve/main/_work/float-layout/probe_typ.py
1.07 kB
| r"""Print the generated typst around each empty float, wide enough to see the material above it. | |
| `probe_empty_where.py` only classifies the 260 characters before the mark; whether the canvas is | |
| inside a block adjacent to the float or merely nearby needs the block structure. | |
| """ | |
| import io | |
| import os | |
| import re | |
| import sys | |
| sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace") | |
| ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | |
| TYPST = os.path.join(ROOT, "typst") | |
| EMPTY = re.compile(r"#figure\(\s*\[\],", re.S) | |
| PAPERS = sys.argv[1:] | |
| for stem in sorted(os.listdir(TYPST)): | |
| if PAPERS and not any(stem.startswith(p) for p in PAPERS): | |
| continue | |
| path = os.path.join(TYPST, stem, "main.typ") | |
| if not os.path.isfile(path): | |
| continue | |
| typ = open(path, encoding="utf-8", errors="replace").read() | |
| for m in EMPTY.finditer(typ): | |
| print("=" * 90) | |
| print("%s at %d" % (stem, m.start())) | |
| print(typ[max(0, m.start() - 3000):m.start() + 700]) | |