Skip to content

Commit 34ce153

Browse files
Merge remote-tracking branch 'origin/main' into pr104-calendar-alias
2 parents 8a32145 + e4bf53b commit 34ce153

77 files changed

Lines changed: 23254 additions & 367 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GOG_TEST_ACCOUNT=your-google-account@example.com
2+
GOG_TEST_DOC_ID=your-test-document-id

.githooks/pre-commit

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "🔍 Running fmt check..."
5+
make fmt-check 2>&1 || {
6+
echo "❌ Format check failed. Run 'make fmt' and re-commit."
7+
exit 1
8+
}
9+
10+
echo "🔍 Running lint..."
11+
if ! make lint 2>&1; then
12+
echo "⚠️ Lint warnings found. Review above before pushing."
13+
echo " To skip: git commit --no-verify"
14+
fi
15+
16+
echo "✅ Pre-commit checks passed."

PR_DESCRIPTION.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
## feat(docs): add sedmat — sed-like document formatting DSL
2+
3+
### What is sedmat?
4+
5+
**Sedmat** is a stream-editor (sed) inspired DSL for formatting Google Docs programmatically. It lets you apply text styling, create tables, insert images, and restructure documents using concise expressions — either one at a time or in batch from `.sed` files.
6+
7+
Think `sed` but for Google Docs formatting instead of text transformation.
8+
9+
### Key Features
10+
11+
- **Brace syntax**`{b i c=red}` for bold, italic, red text; negation with `{!b}`
12+
- **Text styling** — font, size, color, background, alignment, headings, spacing
13+
- **Tables** — create, merge cells, resize columns, apply per-cell formatting
14+
- **Images** — insert from URL, isolation mode, inline placement
15+
- **Batch mode** — process `.sed` files with hundreds of expressions
16+
- **Dry-run** — preview changes without modifying the document
17+
- **Regex flags**`/g` global, `/i` case-insensitive, `/1` first-match-only
18+
- **Positional inserts**`i/pos/text/` to insert at specific document positions
19+
20+
### Usage Examples
21+
22+
```bash
23+
# Bold all occurrences of "important"
24+
gog docs sed <DOC_ID> 's/important/{b}important/g'
25+
26+
# Apply heading style and color from a sed file
27+
gog docs sed <DOC_ID> -f format.sed
28+
29+
# Preview changes without applying
30+
gog docs sed <DOC_ID> 's/draft/{- c=gray}draft/' --dry-run
31+
32+
# Seed a document with content, then format it
33+
gog docs sed <DOC_ID> -f content.txt -p
34+
gog docs sed <DOC_ID> -f styling.sed
35+
```
36+
37+
### Test Coverage
38+
39+
- **17 test files** covering unit, integration, edge cases, and fuzz testing
40+
- Tests run with: `go test ./internal/cmd/... -run Sed -count=1`
41+
- Key function coverage: `Run` 95%, `runBatch` 75%, `classifyExprForBatch` 87%, `runNative` 82%
42+
43+
### File Structure
44+
45+
```
46+
internal/cmd/
47+
├── docs_sed.go # Main entry point, batch/single execution
48+
├── docs_sed_brace.go # Brace expression parser
49+
├── docs_sed_brace_format.go # Brace → Google Docs formatting requests
50+
├── docs_sed_brace_pattern.go # Pattern matching and classification
51+
├── docs_sed_brace_structural.go # Structural formatting (headings, alignment)
52+
├── docs_sed_commands.go # Command registration (cobra)
53+
├── docs_sed_dryrun.go # Dry-run preview engine
54+
├── docs_sed_helpers.go # Shared utilities
55+
├── docs_sed_images.go # Image insertion and isolation
56+
├── docs_sed_insert.go # Positional insert engine
57+
├── docs_sed_manual.go # Built-in manual/help text
58+
├── docs_sed_nesting.go # Nested expression handling
59+
├── docs_sed_parse.go # Expression parser (s/pat/repl/flags)
60+
├── docs_sed_retry.go # Retry with exponential backoff
61+
├── docs_sed_table_cells.go # Table cell operations
62+
├── docs_sed_table_create.go # Table creation
63+
├── docs_sed_table_ops.go # Table merge/resize operations
64+
├── docs_sed_tables.go # Table expression routing
65+
├── docs_sed_*_test.go # 17 test files
66+
docs/
67+
└── sedmat.md # Full DSL reference documentation
68+
testdata/
69+
├── v7-v12_*.sed # Test expression files
70+
└── v7-v12_seed.txt # Test seed documents
71+
```
72+
73+
### Commits
74+
75+
1. **`feat(docs): add sedmat — sed-like document formatting DSL`** — core implementation (18 source files)
76+
2. **`test(sed): comprehensive test suite (~75% overall package coverage, near-100% on core sed functions)`** — 17 test files
77+
3. **`docs(sed): sedmat v3.5 reference documentation`** — full DSL reference

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Fast, script-friendly CLI for Gmail, Calendar, Chat, Classroom, Drive, Docs, Sli
1818
- **Sheets** - read/write/update spreadsheets, insert rows/cols, format cells, read notes, create new sheets (and export via Drive)
1919
- **Forms** - create/get forms and inspect responses
2020
- **Apps Script** - create/get projects, inspect content, and run functions
21-
- **Docs/Slides** - export to PDF/DOCX/PPTX via Drive (plus create/copy, docs-to-text)
21+
- **Docs/Slides** - export to PDF/DOCX/PPTX via Drive (plus create/copy, docs-to-text, and **sedmat** sed-style document editing with Markdown formatting, images, and tables)
2222
- **People** - access profile information
2323
- **Keep (Workspace only)** - list/get/search notes and download attachments (service account + domain-wide delegation)
2424
- **Groups** - list groups you belong to, view group members (Google Workspace)
@@ -1142,8 +1142,32 @@ Note: Classroom commands require a Google Workspace for Education account. Perso
11421142
gog docs export <docId> --format pdf --out ./doc.pdf
11431143
gog docs export <docId> --format docx --out ./doc.docx
11441144
gog docs export <docId> --format txt --out ./doc.txt
1145+
1146+
# Sed-style regex editing with Markdown formatting (sedmat)
1147+
gog docs sed <docId> 's/pattern/replacement/g'
1148+
1149+
# Formatting in replacements
1150+
gog docs sed <docId> 's/hello/**hello**/' # bold
1151+
gog docs sed <docId> 's/hello/*hello*/' # italic
1152+
gog docs sed <docId> 's/hello/~~hello~~/' # strikethrough
1153+
gog docs sed <docId> 's/hello/`hello`/' # monospace
1154+
gog docs sed <docId> 's/hello/__hello__/' # underline
1155+
gog docs sed <docId> 's/Google/[Google](https://google.com)/' # link
1156+
1157+
# Images
1158+
gog docs sed <docId> 's/{{LOGO}}/![](https://example.com/logo.png)/'
1159+
gog docs sed <docId> 's/{{HERO}}/![](https://example.com/hero.jpg){width=600}/'
1160+
1161+
# Tables — create, populate, modify
1162+
gog docs sed <docId> 's/{{TABLE}}/|3x4|/' # create 3-row, 4-col table
1163+
gog docs sed <docId> 's/|1|[A1]/**Name**/' # set cell A1 (bold)
1164+
gog docs sed <docId> 's/|1|[1,*]/**&**/' # bold entire row 1
1165+
gog docs sed <docId> 's/|1|[row:+2]//' # insert row before row 2
1166+
gog docs sed <docId> 's/|1|[col:$+]//' # append column at end
11451167
```
11461168

1169+
> See [docs/sedmat.md](docs/sedmat.md) for the full sedmat syntax reference.
1170+
11471171
### Slides
11481172

11491173
```bash

0 commit comments

Comments
 (0)