Skip to content

Commit 7a09b3f

Browse files
accesswatchclaude
andauthored
feat(release): add an EBAE braille file beside the UEB one (#261)
build-brf.py takes --code ueb|ebae (UEB stays the default). The release and EPUB workflows now build git-going-with-github-ebae.brf, English Braille American Edition grade 2 (liblouis en-us-g2.ctb), alongside the UEB git-going-with-github.brf, whose name is unchanged. Closes #174. Requested by @stickbear2015. Claude-Session: https://claude.ai/code/session_01PmRBrUTuhzYnQBFxUCN6Vr Co-authored-by: Claude <noreply@anthropic.com>
1 parent d052c83 commit 7a09b3f

3 files changed

Lines changed: 30 additions & 8 deletions

File tree

‎.github/workflows/build-epub.yml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ jobs:
4242
run: |
4343
mkdir -p epub/brf
4444
pandoc epub/git-going-with-github.epub -f epub -t plain -o /tmp/book.txt
45-
python3 scripts/build-brf.py /tmp/book.txt epub/brf/git-going-with-github.brf
45+
python3 scripts/build-brf.py /tmp/book.txt epub/brf/git-going-with-github.brf --code ueb
46+
python3 scripts/build-brf.py /tmp/book.txt epub/brf/git-going-with-github-ebae.brf --code ebae
4647
ls -lh epub/brf/
4748
4849
- name: Upload EPUB artifact

‎.github/workflows/create-release.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ jobs:
4343
- name: Build BRF
4444
run: |
4545
pandoc epub/git-going-with-github.epub -f epub -t plain -o /tmp/book.txt
46-
python3 scripts/build-brf.py /tmp/book.txt epub/git-going-with-github.brf
46+
python3 scripts/build-brf.py /tmp/book.txt epub/git-going-with-github.brf --code ueb
47+
python3 scripts/build-brf.py /tmp/book.txt epub/git-going-with-github-ebae.brf --code ebae
4748
4849
- name: Create GitHub Release
4950
uses: softprops/action-gh-release@v2
@@ -61,7 +62,9 @@ jobs:
6162
| **EPUB** | E-readers, Apple Books, Voice Dream, DAISY players |
6263
| **Word (.docx)** | Windows screen readers (JAWS, NVDA), Microsoft Word |
6364
| **BRF** | Braille displays and embossers (UEB Grade 2) |
65+
| **BRF, EBAE** | The same, in English Braille American Edition Grade 2, the US code before UEB |
6466
files: |
6567
epub/git-going-with-github.epub
6668
epub/git-going-with-github.docx
6769
epub/git-going-with-github.brf
70+
epub/git-going-with-github-ebae.brf

‎scripts/build-brf.py‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
#!/usr/bin/env python3
22
"""
33
Convert plain text to BRF (Braille Ready Format) using liblouis.
4-
No TTS required — this is pure text-to-braille-dots translation.
4+
No TTS required: this is pure text-to-braille-dots translation.
55
6-
Usage: python3 build-brf.py input.txt output.brf
6+
Usage: python3 build-brf.py input.txt output.brf [--code ueb|ebae]
7+
8+
--code ueb Unified English Braille, grade 2 (the default)
9+
--code ebae English Braille American Edition, grade 2: the pre-UEB US code,
10+
for readers who prefer it (issue #174)
711
"""
812
import sys
913
import louis
1014

15+
TABLES = {
16+
"ueb": "en-ueb-g2.ctb",
17+
"ebae": "en-us-g2.ctb",
18+
}
19+
1120
# NABCC (North American Braille Computer Code) lookup table.
1221
# Maps 6-dot braille cell bitmask (0-63) to ASCII character.
1322
# bit 0=dot1, bit1=dot2, bit2=dot3, bit3=dot4, bit4=dot5, bit5=dot6
@@ -29,8 +38,17 @@ def unicode_braille_to_brf(text):
2938

3039

3140
def main():
32-
input_file = sys.argv[1] if len(sys.argv) > 1 else "/tmp/book.txt"
33-
output_file = sys.argv[2] if len(sys.argv) > 2 else "output.brf"
41+
args = sys.argv[1:]
42+
code = "ueb"
43+
if "--code" in args:
44+
i = args.index("--code")
45+
if i + 1 >= len(args) or args[i + 1] not in TABLES:
46+
sys.exit("--code must be one of: " + ", ".join(TABLES))
47+
code = args[i + 1]
48+
del args[i:i + 2]
49+
table = TABLES[code]
50+
input_file = args[0] if len(args) > 0 else "/tmp/book.txt"
51+
output_file = args[1] if len(args) > 1 else "output.brf"
3452

3553
with open(input_file, encoding="utf-8", errors="replace") as f:
3654
lines = f.read().split("\n")
@@ -39,7 +57,7 @@ def main():
3957
for line in lines:
4058
if line.strip():
4159
try:
42-
braille = louis.translateString(["en-ueb-g2.ctb"], line)
60+
braille = louis.translateString([table], line)
4361
brf_lines.append(unicode_braille_to_brf(braille))
4462
except Exception:
4563
brf_lines.append(line[:80])
@@ -50,7 +68,7 @@ def main():
5068
with open(output_file, "w", encoding="ascii", errors="replace") as f:
5169
f.write(output)
5270

53-
print(f"BRF written: {len(output):,} bytes, {len(brf_lines):,} lines")
71+
print(f"BRF written ({code.upper()}, {table}): {len(output):,} bytes, {len(brf_lines):,} lines")
5472

5573

5674
if __name__ == "__main__":

0 commit comments

Comments
 (0)