Skip to content

Commit 4d9d950

Browse files
taylorarndtCopilot
andcommitted
Merge documentation/advanced-git-commands: BRF, Word, EPUB build pipeline
- BRF via python3-louis (liblouis Grade 2 braille, zero TTS required) - Word (.docx) via pandoc - EPUB 3 with preprocessed links - All three uploaded as 90-day CI artifacts Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2 parents 2126847 + e67961f commit 4d9d950

File tree

4 files changed

+79
-13
lines changed

4 files changed

+79
-13
lines changed

.github/workflows/build-epub.yml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build EPUB and Word
1+
name: Build EPUB, Word, and BRF
22

33
on:
44
push:
@@ -34,6 +34,17 @@ jobs:
3434
- name: Build EPUB and Word
3535
run: node scripts/build-epub.js
3636

37+
- name: Install liblouis (braille translator — no TTS needed)
38+
run: sudo apt-get install -y liblouis-bin python3-louis
39+
40+
- name: Convert EPUB to BRF (Braille — no TTS required)
41+
continue-on-error: true
42+
run: |
43+
mkdir -p epub/brf
44+
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
46+
ls -lh epub/brf/
47+
3748
- name: Upload EPUB artifact
3849
uses: actions/upload-artifact@v4
3950
with:
@@ -48,14 +59,10 @@ jobs:
4859
path: epub/git-going-with-github.docx
4960
retention-days: 90
5061

51-
- name: Commit outputs to repository
52-
run: |
53-
git config user.name "github-actions[bot]"
54-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
55-
git add epub/git-going-with-github.epub epub/git-going-with-github.docx
56-
if [ -n "$(git status --porcelain)" ]; then
57-
git commit -m "chore: rebuild EPUB and Word from latest docs"
58-
git push
59-
else
60-
echo "No changes to commit"
61-
fi
62+
- name: Upload BRF artifact
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: git-going-with-github-brf
66+
path: epub/brf/
67+
if-no-files-found: warn
68+
retention-days: 90

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,5 @@ podcasts/tts/samples/
167167
*.wav
168168
epub/git-going-with-github.epub
169169
epub/git-going-with-github.docx
170+
epub/git-going-with-github.brf
171+
epub/daisy/

scripts/build-brf.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env python3
2+
"""
3+
Convert plain text to BRF (Braille Ready Format) using liblouis.
4+
No TTS required — this is pure text-to-braille-dots translation.
5+
6+
Usage: python3 build-brf.py input.txt output.brf
7+
"""
8+
import sys
9+
import louis
10+
11+
# NABCC (North American Braille Computer Code) lookup table.
12+
# Maps 6-dot braille cell bitmask (0-63) to ASCII character.
13+
# bit 0=dot1, bit1=dot2, bit2=dot3, bit3=dot4, bit4=dot5, bit5=dot6
14+
NABCC = " A1B'K2L@CIF/MSP\"E3H9O6R^DJG>NTQ,*5<-U8V.%[$+X!&;:4\\0Z7(_?W]#Y)="
15+
16+
17+
def unicode_braille_to_brf(text):
18+
"""Convert Unicode braille characters (U+2800-U+283F) to NABCC ASCII."""
19+
out = []
20+
for ch in text:
21+
code = ord(ch)
22+
if 0x2800 <= code <= 0x283F:
23+
out.append(NABCC[code - 0x2800])
24+
elif code < 128:
25+
out.append(ch)
26+
else:
27+
out.append(" ")
28+
return "".join(out)
29+
30+
31+
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"
34+
35+
with open(input_file, encoding="utf-8", errors="replace") as f:
36+
lines = f.read().split("\n")
37+
38+
brf_lines = []
39+
for line in lines:
40+
if line.strip():
41+
try:
42+
braille = louis.translateString(["en-ueb-g2.ctb"], line)
43+
brf_lines.append(unicode_braille_to_brf(braille))
44+
except Exception:
45+
brf_lines.append(line[:80])
46+
else:
47+
brf_lines.append("")
48+
49+
output = "\n".join(brf_lines)
50+
with open(output_file, "w", encoding="ascii", errors="replace") as f:
51+
f.write(output)
52+
53+
print(f"BRF written: {len(output):,} bytes, {len(brf_lines):,} lines")
54+
55+
56+
if __name__ == "__main__":
57+
main()

scripts/build-epub.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const epubCmd = [
119119
'--toc',
120120
'--toc-depth=2',
121121
'--split-level=1',
122-
'--syntax-highlighting=tango',
122+
'--highlight-style=tango',
123123
'--wrap=none',
124124
fileArgs
125125
].join(' \\\n ');

0 commit comments

Comments
 (0)