|
| 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 |
0 commit comments