Version: 3.7
Last Updated: 2026-11-23
Status: Draft
SEDMAT (Sed-Expression-Driven Markdown Annotation & Transformation) is a specification for rich "WYSIWYG" formatted document manipulation using sed-inspired syntax combined with a compact brace-based formatting DSL ({flags}). SEDMAT provides a portable, human-readable DSL for batch text transformations, formatting operations, and structural modifications targeting rich document formats (Google Docs, Word, Slides, PowerPoint, Sheets, Excel, etc.).
SED is a powerful syntax that is often used by agentic systems to modify source code and other text files. SEDMAT extends that ASCII editing ability into richly formatted documents of any type.
The SEDMAT Brace Syntax is the canonical formatting system. Markdown-style formatting (**bold**, *italic*) is supported as a convenience layer for familiarity but is not the primary syntax.
SEDMAT enables:
- Familiar Syntax: sed-style
[address]s/pattern/replacement/flagsexpressions - Paragraph Addressing: Classic 1-based
sedelement addressing (N,N,M,$,N,$) with document introspection (structure,cat -N) - Rich Formatting: Brace syntax (
{b},{c=red},{h=1}) as the canonical format - Markdown Shortcuts: Optional convenience layer (
**bold**,*italic*) for those familiar with Markdown - Structural Operations: Headings, lists, tables, horizontal rules, blockquotes, code blocks
- Extended sed Commands:
d(delete),a(append),i(insert),y(transliterate) - Regex Power: Full Extended Regular Expression (ERE) support with back-references and
i/m/g/Nflags - Batch Processing: Transform multiple elements via pipelines,
-eexpressions, or-fbatch files - Dry-Run Mode: Preview changes before applying
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.
s/pattern/replacement/That's it! A minimal SEDMAT expression:
- Searches for
pattern - Replaces with
replacement - Affects first match only
# Make the first occurrence of warning bold
s/warning/{b}/
# Bold and preserve matched text explicitly
s/warning/{b t=$0}/
# or shorter, because t defaults to $0
s/warning/{b t}/
# or even shorter, because t defaults to being present
s/warning/{b}/
# Bold + red
s/error/{b c=red}/
# Wrap in link
s/Google/{u=https://google.com}/
# Delete paragraphs containing "DRAFT"
d/DRAFT/
# Address specific paragraphs (1-based, classic sed style)
5d # Delete paragraph 5
3,7s/old/new/g # Substitute only within paragraphs 3 through 7
$a/Appended at the end/ # Append after the last paragraph
# Transliterate vowels
y/aeiou/AEIOU/%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#333333', 'primaryTextColor': '#ffffff', 'primaryBorderColor': '#555555', 'lineColor': '#aaaaaa', 'secondaryColor': '#2a2a2a', 'tertiaryColor': '#222222', 'background': '#111111', 'edgeLabelBackground': '#222222', 'clusterBkg': '#1a1a1a', 'clusterBorder': '#444444' }}}%%
graph LR
subgraph "SEDMAT Expression"
ADDR["[address]"] --> CMD["s|d|a|i|y"]
CMD --> SEP1["/"]
SEP1 --> PAT["pattern"]
PAT --> SEP2["/"]
SEP2 --> REP["replacement"]
REP --> SEP3["/"]
SEP3 --> FLAGS["flags"]
end
style ADDR fill:#2a3a4a,color:#ffffff,stroke:#4a6a8a
style CMD fill:#1a4a1a,color:#ffffff,stroke:#2a7a2a
style PAT fill:#4a3a1a,color:#ffffff,stroke:#7a5a2a
style REP fill:#1a2a4a,color:#ffffff,stroke:#2a4a7a
style FLAGS fill:#4a1a3a,color:#ffffff,stroke:#7a2a5a
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#333333', 'primaryTextColor': '#ffffff', 'primaryBorderColor': '#555555', 'lineColor': '#aaaaaa', 'secondaryColor': '#2a2a2a', 'tertiaryColor': '#222222', 'background': '#111111', 'edgeLabelBackground': '#222222' }}}%%
flowchart TB
INPUT[Input Document] --> PARSE[Parse Expression]
PARSE --> ADDR{Has Address<br/>Prefix?}
ADDR -->|Yes| RESOLVE[Resolve 1-Based<br/>Element Range]
ADDR -->|No| CMD{Command<br/>Type?}
RESOLVE --> CMD
CMD -->|s| HASFORMAT{Contains<br/>Formatting?}
CMD -->|d| DELETE[Delete Targeted<br/>Paragraphs]
CMD -->|a/i| INSERT[Insert/Append<br/>Paragraphs]
CMD -->|y| XLAT[Transliterate<br/>Characters]
HASFORMAT -->|No| NATIVE[Native Regex API<br/>Fast Path]
HASFORMAT -->|Yes| BRACEPARSE[Parse Brace Syntax]
BRACEPARSE --> WALK[Document Walk<br/>Full Processing]
NATIVE --> OUTPUT[Output Document]
WALK --> OUTPUT
DELETE --> OUTPUT
INSERT --> OUTPUT
XLAT --> OUTPUT
style RESOLVE fill:#2a3a4a,color:#ffffff,stroke:#4a6a8a
style NATIVE fill:#1a4a1a,color:#ffffff,stroke:#2a7a2a
style WALK fill:#4a3a1a,color:#ffffff,stroke:#7a5a2a
style BRACEPARSE fill:#3a2a4a,color:#ffffff,stroke:#5a4a7a
SEDMAT processors SHOULD detect plain-text replacements and use native regex APIs for optimal performance.
All mutating commands (s, d, a, i) MAY be preceded by an optional 1-based Paragraph Address (N, N,M, $, N,$) to restrict the operation to specific document elements.
The core command. Matches pattern in the document (or within the addressed elements) and replaces with replacement.
s/old/new/ # Replace first match
s/old/new/g # Replace all matches
s/old/new/i # Case-insensitive first match
s/old/new/gi # Case-insensitive, all matches
s/old/new/2 # Replace 2nd match only
5s/.*/New text/ # Replace all text in paragraph 5
3,7s/old/new/g # Replace all matches within paragraphs 3 through 7Deletes entire paragraphs matching pattern, or deletes elements selected by a Paragraph Address. When both an address and a pattern are supplied (N,Md/pattern/), only addressed elements matching pattern are deleted.
d/DRAFT/ # Delete paragraphs containing "DRAFT"
d/draft/i # Case-insensitive delete
d/^$/ # Delete empty paragraphs
d/TODO.*/ # Delete paragraphs matching regex
5d # Delete element 5
3,7d # Delete elements 3 through 7
$d # Delete last element
3,$d # Delete from element 3 to the end
3,7d/DRAFT/ # Delete elements in 3..7 containing "DRAFT"Appends text as a new paragraph after each paragraph matching pattern, or immediately after each addressed element. When an address prefix is present, no search pattern is required ([address]a/text/).
a/Introduction/This text appears after the Introduction paragraph/
a/^Chapter/--- end of chapter ---/
5a/New paragraph after element 5/
$a/Appended at the end of the document/Inserts text as a new paragraph before each paragraph matching pattern, or immediately before each addressed element. When an address prefix is present, no search pattern is required ([address]i/text/).
i/Conclusion/This text appears before the Conclusion paragraph/
i/^Chapter/=== start of chapter ===/
3i/Inserted before element 3/
1i/{h=t}Document Title/Character-for-character transliteration, like sed's y command. Each character in source is replaced with the corresponding character in dest. Both strings MUST be the same length.
y/aeiou/AEIOU/ # Uppercase vowels
y/abc/xyz/ # a→x, b→y, c→z
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ # LowercaseStatus: ✅ STABLE (added in v3.6) — Adopts classic
sed1-based line addressing for top-level rich document elements.
Rich documents are composed of ordered top-level structural elements (paragraphs, tables, and tables of contents). Classic sed-style address prefixes allow targeting specific elements deterministically by 1-based ordinal index — avoiding fragile substring matching when editing repeating headings, boilerplate, or long documents.
Implementations MUST assign sequential 1-based indices (1, 2, ..., N) in document order across top-level body elements of the active document (or active tab/section):
| Element Kind | Description |
|---|---|
paragraph |
Body paragraphs, headings, list items, blockquotes, horizontal rules, code lines |
table |
Top-level tables (counted as a single addressable top-level element) |
toc |
Table of contents blocks |
| Address | Meaning |
|---|---|
N |
Element number N (1-based positive integer) |
N,M |
Inclusive range from element N through element M (M >= N) |
$ |
Last addressable element in the document (or active tab/section) |
N,$ |
Inclusive range from element N through the last element |
| Form | Semantics |
|---|---|
Nd, N,Md, $d, N,$d |
Unconditionally delete addressed element(s) |
N,Md/pattern/[flags] |
Delete addressed elements whose text matches pattern |
Ns/pat/rep/[flags], N,Ms/pat/rep/[flags] |
Substitute only within addressed element(s) |
Na/text/, N,Ma/text/, $a/text/ |
Append new paragraph(s) after each addressed element (no search pattern) |
Ni/text/, N,Mi/text/, $i/text/ |
Insert new paragraph(s) before each addressed element (no search pattern) |
Literal \n escapes inside addressed a/text/ and i/text/ payloads MUST be expanded to paragraph breaks.
Implementations MUST enforce the following address validation errors before mutating the document:
- Address without command: An address prefix with no following command (e.g.,
5,1,3,$) MUST fail with a parse error. $as range start:$,Nand$,$MUST fail with a parse error (useN,$instead).- Malformed range: A trailing comma (
3,) or non-numeric /< 1range bound (0,3,0,3,foo) MUST fail with a parse error. - Reversed range:
N,MwhereM < NMUST fail with an error. - Empty document: Resolving any address against a document with zero addressable elements MUST fail with an error.
- Out-of-range index: Resolving
start > element_countorend > element_countMUST fail with an out-of-range error reporting the actual element count.
Many rich document models (such as Google Docs and OOXML body segments) require a non-deletable trailing paragraph sentinel / final newline. When planning addressed deletions that include the final element:
- Contiguous terminal range (
N,$dwhereN < last): Implementations SHOULD plan a single contiguous deletion ending immediately before the final element's mandatory trailing newline so the document remains structurally valid. - Single final element (
$dwherelast > 1): Implementations MUST remove from the preceding element's trailing newline through immediately before the final newline (so no stray empty paragraph is left behind). - Sole element (
1d/$dwhenlast == 1): Implementations MUST clear the element's text content while preserving the required empty document paragraph.
Because deterministic paragraph addressing requires knowing element numbers, CLI tools and agent integrations SHOULD provide read-only introspection views using the exact same 1-based numbering as SEDMAT addressing:
- Structure listing (
structure): Displays each element's 1-based index, kind (paragraph,table,toc), style/heading level, and a short text preview. - Numbered output (
cat -N): Outputs document text prefixed with[1],[2],[3], ... per addressable element.
# Discover element numbers before editing
gog docs structure <DOC_ID>
gog docs cat <DOC_ID> -N
# Apply deterministic addressed edits
gog docs sed <DOC_ID> '5d'
gog docs sed <DOC_ID> '3,7s/draft/final/gi'
gog docs sed <DOC_ID> '$a/Appendix A/'For multi-tab or multi-section documents (e.g., Google Docs Tabs, Word sections, Slides, Sheets), CLI implementations SHOULD support --tab <title-or-id> (or --slide / --sheet) as shorthand for an implicit inline Container Scope (@):
gog docs structure <DOC_ID> --tab "Summary"
gog docs sed <DOC_ID> --tab "Summary" '3d'Status: 🧪 DRAFT (added in v3.7) — Format-agnostic container addressing unifying PowerPoint Slides, Excel/Sheets Worksheets, Google Docs Tabs, Word Sections/Headers/Footers, and PDF Pages without per-app prefix collisions.
Bare numeric addresses (1, 3,7, $) ALWAYS address content inside the active container (paragraphs, rows, blocks). To address the container itself or scope edits to specific containers and named sub-regions, prefix an expression with @:
| Form | Example | Semantics |
|---|---|---|
Container-level ops (no :) |
@3d, @2,4d, @$d |
Delete container(s) (Slide / Sheet / Tab / Page) |
@$a/{layout=two-col}Next Steps/ |
Append a new container after the last container | |
@2i/{layout=content}Overview/ |
Insert a new container before container 2 | |
@3{move=1}, @2{dup}, @4{hide} |
Move, duplicate, or hide a container | |
Container-scoped edits (@<target>:) |
@2:s/500ms/{b c=green t=120ms}/g |
Substitute within container 2 |
@2,5:s/Voxio/{b c=blue}/g |
Substitute across containers 2–5 | |
@2:2d, @2:1,3s/old/new/g |
1-based paragraph/element addressing inside container 2 | |
@*:s/DRAFT//g |
All containers (equivalent to unscoped) | |
| Named containers | @Summary:3d, @"Q4 Budget":s/USD/EUR/g |
Select container by title/name (unifies --tab / --sheet) |
| Optional typed sugar | @slide=2:..., @sheet=Budget:..., @tab=Summary:..., @page=4:... |
Explicit container-type assertion |
Named sub-regions (@<target>:<region>:) |
@2:title:s/.*/{c=navy}New Title/ |
PowerPoint title placeholder (title, sub, body, notes, shape=N) |
@2:notes:a/Pause for Q&A./ |
PowerPoint speaker notes | |
@header:s/DRAFT/FINAL/, @1:footer:s/2025/2026/ |
Word / Docs headers & footers | |
| Tables & Images in scope | @2:{T=1!A1}/{b}Metric/, @2:{img=1}/{x=480}/ |
Scoped table/image ops inside container 2 |
| Flag | Example | Effect |
|---|---|---|
layout= |
{layout=two-col} |
Slide layout (title, content, two-col, section, comparison, blank) |
zone= |
{zone=left} |
Semantic placement zone (left, right, top, bottom, center, footer) |
shape= |
{shape=roundRect fill=#1E293B stroke=#38BDF8} |
Preset shape geometry, fill, and stroke |
notes= |
@2:{notes="Talk track"} |
Set speaker notes inline (parallels {"=comment}) |
transition= |
@2:{transition=fade} |
Slide transition (none, fade, push, wipe) |
move=, dup, hide |
@3{move=1}, @2{dup}, @4{hide} |
Structural container mutations |
@1:{z=#0F172A}
@1:title:s/.*/{c=white s=40}Voxio 2.0 Architecture/
@1:sub:s/.*/{c=#94A3B8}Voice-Native Office Studio/
@2:body:s/(\d+ms)/{b c=green}$1/g
@2:notes:s/.*/Highlight the 120ms WebTransport benchmark./
@$a/{layout=two-col}Before vs After/
@$:{T=1!A1}/{b}Metric/| Flag | Meaning | Applies To | Status |
|---|---|---|---|
g |
Replace ALL matches | s |
✅ STABLE |
i |
Case-insensitive regex matching ((?i)) |
s, d, a, i |
✅ STABLE |
m |
Multiline mode (^/$ match line boundaries, (?m)) |
s, d, a, i |
✅ STABLE |
N (1..N) |
Replace Nth occurrence only | s |
✅ STABLE |
| (none) | Replace first match only | s |
✅ STABLE |
Flag combinations: Flags MAY be combined in any order (e.g., s/foo/bar/gi, s/^line/LINE/gim, d/draft/i). Positive integers select the Nth occurrence (s/foo/bar/2, s/foo/bar/10).
s/foo/bar/g # All occurrences
s/foo/bar/i # Case-insensitive (first match)
s/foo/bar/gi # Case-insensitive + global
s/foo/bar/2 # 2nd occurrence only
s/^line/LINE/m # Multiline: ^ matches start of each line
s/^line/LINE/gm # Multiline + global
d/draft/i # Delete paragraphs matching "draft" (any case)Conformance: Implementations MUST support g, i (case-insensitive), m (multiline), and N (nth occurrence) flags.
The delimiter / MAY be replaced with any consistent character not appearing in the pattern or replacement:
# Standard
s/path/to/file/replacement/
# Alternate delimiter (when pattern contains /)
s#path/to/file#replacement#
s|path/to/file|replacement|Implementations MUST support at minimum /, #, and | as delimiters.
Status: ✅ STABLE — Brace Syntax is the canonical formatting system in SEDMAT. All brace syntax features are REQUIRED for conformant implementations.
Brace Syntax is the primary formatting system in SEDMAT replacement strings. It uses {key=value} pairs and {flag} toggles inside curly braces to specify formatting, structural, and semantic attributes.
Where Markdown uses wrapper characters (**bold**, *italic*), Brace Syntax uses flag-based declarations:
# Brace Syntax (canonical)
s/error/{b}/g
# Brace Syntax with color (no Markdown equivalent)
s/error/{b c=red}/g
# Markdown style (convenience alternative)
s/error/**error**/gBrace Syntax is particularly useful for expressing attributes that have no Markdown equivalent (color, font, size, background, headings, breaks, comments, bookmarks, smart chips).
-
t=defaults to$0— The implicit text flag preserves the matched text. Writing{b}is equivalent to{b t=$0}. The matched text is automatically preserved unless you explicitly override it witht=something. -
Boolean flags need no
=y— Simply{b i _}for bold + italic + underline. -
Bare value flags reset to defaults —
{f s c z}resets font to Arial, size to 11pt, color to black, background to clear. -
{0}resets ALL formatting — Acts like CSSall: unset. MAY be combined:{0 b}resets everything then applies bold. -
Inline scoping with
{flag=text}— Boolean flags accept optional=textto scope the style to just that text inline (see Inline Scoping). -
Structural flags target containers — Most flags target text ranges, but structural flags (
cols=,+=, and future page-level properties) target the containing section or document. The matched text acts as a locator to identify which section to modify. Both text flags and structural flags coexist in the same{}group — implementations apply each to its appropriate scope. -
Flexible brace placement — When paired with literal replacement text outside the braces, a brace block MAY be placed before the text (
{b}hello, preferred), after the text (hello{b}), or surrounding the text ({c=red}warning{b}, merging both brace groups onto the text). Standalone braces ({b}) apply to$0via the implicitt=$0rule, and multiple brace blocks interleaved with text produce independent styled spans.
This is the most important design rule. When you write a standalone brace expression, the matched text ($0) is implicitly preserved:
# These are equivalent:
s/warning/{b}/g
s/warning/{b t=$0}/g
# The replacement is "warning" with bold appliedWhen replacing the text itself, you MAY either use t= inside the braces or place the brace block adjacent to the replacement text:
# Replace "error" with "ERROR" and make it bold (all equivalent)
s/error/{b t=ERROR}/g
s/error/{b}ERROR/g # Braces before text (canonical)
s/error/ERROR{b}/g # Braces after text
s/error/{c=red}ERROR{b}/g # Surrounding braces merge flags (red + bold)
# Replace with back-reference
s/(\w+)/{b t=[$1]}/g # "hello" → "[hello]" in bold
s/(\w+)/{b}[$1]/g # EquivalentIf you omit brace syntax entirely, you're doing a plain text replacement:
# Plain replacement (no formatting)
s/old/new/gBoolean flags are activated by presence alone. No =y is needed.
| Short | Long | Effect |
|---|---|---|
b |
bold |
Bold |
i |
italic |
Italic |
_ |
underline |
Underline |
- |
strike |
Strikethrough |
# |
code |
Monospace/code |
^ |
sup |
Superscript (entire replacement) |
, |
sub |
Subscript (entire replacement) |
w |
smallcaps |
Small caps |
check |
— | Checkbox (tri-state: absent/=n/=y) |
Examples:
s/important/{b}/g # Bold
s/emphasis/{i}/g # Italic
s/code/{#}/g # Monospace
s/deleted/{-}/g # Strikethrough
s/term/{_ i}/g # Underline + italicBoolean flags accept optional =text for inline scoping. This allows you to apply a style to just a portion of the replacement text, rather than the entire match.
{b}alone as entire replacement = bold the whole match (implicit{b=$0}){b=text}embedded in replacement = bold just "text" inline
All 8 boolean flags support inline scoping:
| Flag | Inline Form | Effect |
|---|---|---|
b |
{b=text} |
Bold just "text" |
i |
{i=text} |
Italicize just "text" |
_ |
{_=text} |
Underline just "text" |
- |
{-=text} |
Strikethrough just "text" |
# |
{#=text} |
Monospace just "text" |
^ |
{^=text} |
Superscript just "text" |
, |
{,=text} |
Subscript just "text" |
w |
{w=text} |
Small caps just "text" |
Chemistry (subscripts):
s/H2O/H{,=2}O/g # H₂O — subscript only the "2"
s/CO2/CO{,=2}/g # CO₂
s/C6H12O6/C{,=6}H{,=12}O{,=6}/g # Glucose formulaMath (superscripts):
s/x2/x{^=2}/g # x² — superscript only the "2"
s/E=mc2/E=mc{^=2}/g # E=mc²
s/x2\+y2=z2/x{^=2}+y{^=2}=z{^=2}/g # Pythagorean theoremProse (emphasis):
s/Warning: read this/{b=Warning}: read this/g # Bold only "Warning"
s/Note: important/{i=Note}: important/g # Italic only "Note"
s/Action Required: do it/{b=Action} {i=Required}: do it/g # Mix inline stylesCode spans:
s/Run npm install to start/{#=npm install}/g # Monospace just the command
s/Use the --force flag/{#=--force}/g # Monospace just the flagStrikethrough (pricing, edits):
s/\$\$99 now \$\$49/{-=$$99} now $$49/g # Strike the old price
s/was 100 now 75/{-=was 100} now 75/g # Strike the old textFor applying multiple styles to the same inline text, use t=:
# Bold + red for "WARNING"
s/WARNING: danger/{b c=red t=WARNING}: danger/g
# Bold + italic + underline for a term
s/important term/{b i _ t=important term}/gNote: {b=text} is syntactic sugar for {b t=text} when used inline. The t= form is required when combining multiple styles on one span.
Use ! prefix to explicitly turn off a flag:
s/already bold/{!b}/g # Remove bold
s/styled/{!b !i !_}/g # Remove multiple stylesNote: The
=nsuffix for negation (e.g.,{b=n}) is no longer supported as of v3.3. The=on boolean flags now indicates inline scoping (e.g.,{b=text}). Use the!prefix for all negation.
Multiple boolean flags MAY appear in a single brace group:
s/critical/{b i _}/g # Bold + italic + underline
s/code/{# -}/g # Monospace + strikethrough
s/warning/{b i c=red}/g # Bold + italic + red colorValue flags use key=value syntax. When a value flag appears bare (without =value), it resets to its default.
| Short | Long | Default (bare) | Effect |
|---|---|---|---|
t |
text |
$0 (matched text) |
Replacement text |
c |
color |
black | Text color (hex or named) |
z |
bg |
clear | Background/highlight color |
f |
font |
Arial | Font family |
s |
size |
11pt | Font size in points |
u |
url |
(strip link) | Link/URL/URI |
h |
heading |
HEADING_1 | Heading level |
l |
leading |
1.15 | Line height |
a |
align |
left | Text alignment |
o |
opacity |
100 | Opacity (percentage) |
n |
indent |
0 | Indent level |
k |
kerning |
0 | Letter spacing |
x |
width |
— | Width in pixels |
y |
height |
— | Height in pixels |
p |
spacing |
default | Paragraph spacing above/below (pt or above,below) |
e |
effect |
— | Shadow/glow/blur |
cols |
— | 1 | Number of columns in containing section |
toc |
— | — | Insert table of contents (optional =N for max depth) |
Examples:
# Colors
s/error/{c=red}/g
s/warning/{c=#FFA500}/g # Orange (hex)
s/highlight/{z=yellow}/g # Yellow background
# Fonts and sizes
s/heading/{f=Georgia s=18}/g
s/caption/{s=9 i}/g
# Text alignment
s/Title/{a=center h=t}/g # Centered title
s/disclaimer/{a=right s=8}/g # Right-aligned small text
s/body text/{a=justify}/g # Justified paragraph
# Indent levels
s/sub-point/{n=1}/g # Indent level 1
s/sub-sub-point/{n=2}/g # Indent level 2
s/outdent/{n=0}/g # Reset to no indent
# Line spacing
s/dense text/{l=1}/g # Single spacing
s/readable/{l=1.5}/g # 1.5 spacing
s/double spaced/{l=2}/g # Double spacing
# Combined
s/CRITICAL/{b c=red z=yellow s=14}/gSEDMAT defines a standard named color palette for the c= (color) and z= (background) flags. Implementations MUST support hex notation (#RRGGBB). Named colors are RECOMMENDED.
| Name | Hex | Name | Hex |
|---|---|---|---|
black |
#000000 | white |
#FFFFFF |
red |
#FF0000 | green |
#00FF00 |
blue |
#0000FF | yellow |
#FFFF00 |
cyan |
#00FFFF | magenta |
#FF00FF |
orange |
#FF8C00 | purple |
#800080 |
pink |
#FF69B4 | brown |
#8B4513 |
gray / grey |
#808080 | lightgray |
#D3D3D3 |
darkgray |
#404040 | navy |
#000080 |
teal |
#008080 |
Examples:
# These are equivalent:
s/error/{c=red}/g
s/error/{c=#FF0000}/g
# Named colors for readability
s/warning/{c=orange z=yellow}/g
s/info/{c=navy}/g
s/success/{c=green b}/g
s/muted/{c=gray}/gThe {0} flag resets ALL formatting to defaults, like CSS all: unset:
s/messy text/{0}/g # Strip all formatting
s/messy text/{0 b}/g # Reset then apply bold only
s/weird font/{0 f=Arial}/g # Reset then set fontConversely, {!0} explicitly opts out of any implicit formatting reset (additive mode), ensuring co-occurring flags layer onto existing text formatting rather than clearing untouched attributes:
s/styled text/{!0 c=red}/g # Add red color while preserving existing bold/font/size
s/heading/{!0 i}/g # Add italic additively without resetting existing stylesYou can also reset individual attributes by using bare value flags:
s/text/{f s c z}/g # Reset font, size, color, backgroundThe h flag controls heading level using compact shorthands:
| Syntax | Maps to |
|---|---|
{h=t} |
TITLE |
{h=s} |
SUBTITLE |
{h=1} |
HEADING_1 |
{h=2} |
HEADING_2 |
{h=3} |
HEADING_3 |
{h=4} |
HEADING_4 |
{h=5} |
HEADING_5 |
{h=6} |
HEADING_6 |
{h} (bare) |
HEADING_1 (default heading) |
{h=0} |
NORMAL_TEXT (reset heading) |
Examples:
s/My Document/{h=t}/g # Set as Title
s/Overview/{h=s}/g # Set as Subtitle
s/Chapter 1/{h=1 b}/g # Heading 1 + bold
s/Section/{h=2}/g # Heading 2
s/heading text/{h}/g # Apply default heading (HEADING_1)
s/normal paragraph/{h=0}/g # Reset to normal textThe p flag controls paragraph spacing (space above and below the paragraph).
| Syntax | Effect |
|---|---|
{p=12} |
12pt spacing both above and below |
{p=12,6} |
12pt above, 6pt below (comma-separated) |
{p=0} |
No spacing (tight paragraphs) |
{p=0,12} |
No spacing above, 12pt below |
{p} (bare) |
Reset to default spacing |
Examples:
# Tight title with space below
s/Title/{h=1 p=0,24}/g
# Generous spacing for readability
s/Section/{h=2 p=24,12}/g
# No spacing for compact lists
s/item/{p=0}/g
# Reset to defaults
s/paragraph/{p}/gSEDMAT provides boolean flags for super/subscript with inline scoping support.
The {^} (superscript) and {,} (subscript) flags apply to the entire replacement text when used alone:
s/TM/{^}/g # "TM" as superscript → ᵀᴹ
s/2/{,}/g # "2" as subscript → ₂
s/note/{,}/g # "note" entirely as subscriptUse {^=text} and {,=text} to apply super/subscript to just part of the replacement:
# Chemistry
s/H2O/H{,=2}O/g # H₂O
s/CO2/CO{,=2}/g # CO₂
s/H2SO4/H{,=2}SO{,=4}/g # H₂SO₄
# Math
s/E=mc2/E=mc{^=2}/g # E=mc²
s/x2\+y2=z2/x{^=2}+y{^=2}=z{^=2}/g # x²+y²=z²
# Ordinals
s/1st/1{^=st}/g # 1ˢᵗ
s/2nd/2{^=nd}/g # 2ⁿᵈFor simple cases, Unicode super/subscript characters work directly:
s/H2O/H₂O/g # Unicode subscript 2
s/E=mc2/E=mc²/g # Unicode superscript 2Unicode superscript: ⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁼⁽⁾ⁿ
Unicode subscript: ₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎
The + key inserts structural breaks. When used alone, it inserts a horizontal rule. With a value, it specifies the break type:
| Syntax | Effect |
|---|---|
{+} |
Horizontal rule (default) |
{+=p} |
Page break |
{+=c} |
Column break |
{+=s} |
Section break |
Examples:
s/---/{+}/g # Horizontal rule
s/END/{+=p}/g # Page break
s/COLUMN_BREAK/{+=c}/g # Column break
s/SECTION_END/{+=s}/g # Section breakThe cols= flag is a structural flag that sets the number of columns in the section containing the match. The matched text acts as a locator to identify which section to modify.
| Syntax | Effect |
|---|---|
{cols=2} |
2-column layout |
{cols=1} |
Single column (default) |
{cols=3} |
3-column layout |
{cols} (bare) |
Reset to 1 column |
| Flag Type | Target | Examples |
|---|---|---|
| Text flags | Matched text range | {b}, {c=red}, {h=1} |
| Structural flags | Containing section | {cols=2}, {+=s}, {+=p} |
Both coexist in the same {} group:
# h=1 and b apply to text; cols=2 applies to section
s/Chapter/{h=1 b cols=2}/g# Section break + set new section to 2 columns
s/NEWSLETTER_START/{+=s cols=2}/g
# Return to single column for footer
s/FOOTER_START/{+=s cols=1}/g# Force content to next column
s/NEXT_COLUMN/{+=c}/gs/^/{h=t t=Monthly Newsletter}\n/
s/ARTICLES/{+=s cols=2 h=2 t=Articles}/g
s/ARTICLE_BREAK/{+=c}/g
s/FOOTER/{+=s cols=1 h=2 t=Contact}/gThe check flag creates native checklist items (Google Docs checkboxes). Unlike other boolean flags, check has tri-state semantics:
| Syntax | Effect |
|---|---|
| (absent) | No checkbox |
{check} or {check=n} |
Unchecked checkbox ☐ |
{check=y} |
Checked checkbox ☑ |
Examples:
# Convert TODO markers to unchecked checkboxes
s/TODO/{check=n}/g
# Convert DONE markers to checked checkboxes
s/DONE/{check=y}/g
# Checkbox + bold
s/task/{check=n b}/g
# Build a checklist from placeholders
s/\[ \]/{check=n}/g
s/\[x\]/{check=y}/g# Transform a list into a checklist
s/- pending/{check=n t=pending}/g
s/- complete/{check=y t=complete}/g
# Add checkbox to all list items
s/^- (.+)/{check=n t=$1}/gmThe toc flag inserts a table of contents generated from document headings (h=1 through h=6).
| Syntax | Effect |
|---|---|
{toc} |
Full TOC (all heading levels) |
{toc=N} |
TOC with max depth N |
Examples:
# Insert TOC at placeholder
s/{{TOC}}/{toc}/
# Prepend TOC to document
s/^/{toc}\n/
# TOC with only h1 and h2
s/{{TOC}}/{toc=2}/
# TOC after title
s/Introduction/{toc}\n\nIntroduction/Implementations SHOULD auto-link TOC entries to their corresponding headings.
The " key attaches a comment (annotation) to the matched text:
s/TODO/{"=needs review}/g # Just a comment
s/TODO/{"=needs review b c=red}/g # Comment + bold + red
s/FIXME/{"=assigned to viz b}/g # Comment with formattingCreate bookmark anchors and link to them:
| Syntax | Effect |
|---|---|
{@=name} |
Creates a bookmark anchor on the matched text |
{u=#name} |
Links to a bookmark by name |
Examples:
# Create a bookmark anchor
s/Chapter 1/{@=ch1 h=1}/g # Bookmark + heading
# Link to the bookmark
s/see Chapter 1/{u=#ch1 c=blue _}/g # Link to bookmark + styling
# Create anchor and style
s/Definition/{@=def1 b}/g
# Reference it elsewhere
s/as defined above/{u=#def1}/gThe u flag accepts any valid URI. SEDMAT defines standard schemes and custom chip:// schemes for Google Docs smart chips.
| Scheme | Example |
|---|---|
https:// |
{u=https://deft.md} |
http:// |
{u=http://example.com} |
mailto: |
{u=mailto:viz@example.com} |
tel: |
{u=tel:+14076163470} |
geo: |
{u=geo:28.69,-81.31} |
sms: |
{u=sms:+14076163470} |
webcal: |
{u=webcal://feed.ics} |
file: |
{u=file:///path} |
Examples:
s/Google/{u=https://google.com}/g
s/contact/{u=mailto:hello@example.com}/g
s/call us/{u=tel:+14075551234}/g
s/location/{u=geo:28.5383,-81.3792}/gFor Google Docs smart chip insertion:
| Scheme | Example | Effect | Notes |
|---|---|---|---|
chip://person/ |
{u=chip://person/viz@example.com} |
Person smart chip | |
chip://date/ |
{u=chip://date/2026-03-15} |
Date smart chip | |
chip://file/ |
{u=chip://file/DOC_ID} |
File link chip | |
chip://place/ |
{u=chip://place/Orlando, FL} |
Place chip | |
chip://dropdown/ |
{u=chip://dropdown/Draft|Review|Done} |
Dropdown chip | |
chip://chart/ |
{u=chip://chart/SHEET_ID/0} |
Chart embed | |
chip://bookmark/ |
{u=chip://bookmark/section-1} |
Internal doc link | Prefer {u=#name} shorthand |
Examples:
s/viz/{u=chip://person/jtaylor@zendicate.com}/g
s/deadline/{u=chip://date/2026-03-15}/g
s/project doc/{u=chip://file/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms}/g
s/status/{u=chip://dropdown/Draft|Review|Done}/gTwo approaches for embedding charts from Google Sheets:
s/CHART/{u=chip://chart/SHEET_ID/0 x=600 y=400}/gPulls chart at index 0 from the linked Sheet and embeds it at 600×400 pixels.
gog sheets chart SHEET_ID 0 --png | gog docs sed DOC_ID 's/PLACEHOLDER/{img=-1}/g'Export chart as image, then insert via pipe.
# Simple styling
s/error/{b c=red}/g
s/TODO/{b c=red z=yellow}/g
s/note/{i c=gray s=10}/g
# Text replacement with formatting
s/old text/{b t=new text}/g
s/(\w+)/{i t=[$1]}/g
# Inline scoping
s/H2O/H{,=2}O/g # Subscript just "2"
s/E=mc2/E=mc{^=2}/g # Superscript just "2"
s/Warning: stop/{b=Warning}: stop/g # Bold just "Warning"
s/Run npm install/{#=npm install}/g # Monospace the command
# Reset formatting
s/messy text/{0}/g
s/messy text/{0 b}/g # Reset then bold
# Links and chips
s/viz/{u=chip://person/jtaylor@zendicate.com}/g
s/deadline/{u=chip://date/2026-03-15}/g
s/call me/{u=tel:+14075551234}/g
s/website/{u=https://example.com c=blue _}/g
# Headings
s/My Doc/{h=t}/g
s/Overview/{h=s}/g
s/Chapter 1/{h=1 b}/g
# Superscript and subscript
s/TM/{^}/g
s/note/{,}/g
s/CO2/CO{,=2}/g
s/x2/x{^=2}/g
# Breaks
s/END/{+=p}/g
s/---/{+}/g
s/SECTION/{+=s}/g
# Columns
s/NEWSLETTER/{+=s cols=2}/g # Section break + 2 columns
s/FOOTER/{+=s cols=1}/g # Back to single column
s/NEXT_COL/{+=c}/g # Column break
# Checkboxes
s/TODO/{check=n}/g # Unchecked
s/DONE/{check=y}/g # Checked
s/task/{check=n b}/g # Checkbox + bold
# Table of contents
s/{{TOC}}/{toc}/ # Full TOC
s/{{TOC}}/{toc=2}/ # TOC depth 2
# Comments and bookmarks
s/TODO/{@=todo1 "=needs review b c=red}/g
s/see above/{u=#todo1 c=blue _}/g
# Combined
s/WARNING/{b i c=red s=14 z=yellow}/g
s/https\S+/{u=$0 c=blue _}/gSEDMAT supports capture groups using (...) with references via $1-$9 or \1-\9:
# Capture and format
s/(important)/{b t=$1}/g
# Bold all-caps words (2+ chars)
s/([A-Z]{2,})/{b t=$1}/g
# Wrap names in links
s/(@\w+)/{u=https://twitter.com/$1 t=$1}/g| Reference | Alternative | Meaning |
|---|---|---|
$0 |
& |
Entire match |
$1 |
\1 |
First capture group |
$2 |
\2 |
Second capture group |
$n |
\n |
Nth capture group (1-9) |
The & represents the entire matched text (like sed). Use \& for a literal ampersand.
# Wrap every match in brace formatting
s/important/{b}/g # Implicit: {b t=$0}
# Using & explicitly in plain replacement
s/important/(**&**)/g # Markdown-style with parens
# Literal ampersand
s/rock/rock \& roll/ # \& = literal &Use $$ for a literal dollar sign in replacements:
s/PRICE/$$49.99/g # Outputs: $49.99
s/COST/$$100/g # Outputs: $100Conformance: Implementations MUST support $1-$9, $0, &, and $$ notation. Support for \1-\9 is RECOMMENDED for sed compatibility.
| Syntax | Effect | Status |
|---|---|---|
[text](url) |
Hyperlink with text | REQUIRED |
<url> |
Auto-link (bare URL) | REQUIRED |
[text](url "title") |
Link with title attribute | RECOMMENDED |
{u=url} |
Brace syntax link | REQUIRED |
Examples:
# Markdown-style link
s/Google/[Google](https:\/\/google.com)/
# Brace syntax link (canonical)
s/Google/{u=https://google.com}/
# Link with styling
s/Google/{u=https://google.com c=blue _}/
# Link email addresses
s/(\S+@\S+)/[$1](mailto:$1)/g
# Auto-link bare URLs
s/(https:\/\/\S+)/<$1>/g| Syntax | Effect | Status |
|---|---|---|
 |
Image, no alt text | ✅ RECOMMENDED |
 |
Image with alt text | ✅ RECOMMENDED |
 |
Image with caption | ✅ RECOMMENDED |
{x=N} |
Width in pixels | ✅ STABLE |
{y=N} |
Height in pixels | ✅ STABLE |
{x=N y=M} |
Both dimensions | ✅ STABLE |
Examples:
# Insert at placeholder (standard markdown)
s/{{LOGO}}//
# With alt text
s/{{LOGO}}//
# With dimensions (brace syntax)
s/{{HERO}}/{x=600}/
s/{{BANNER}}/{x=800 y=200}/Status: ✅ STABLE — The
{img=}brace syntax is the canonical way to reference existing images by position or pattern.
| Syntax | Meaning | Status |
|---|---|---|
{img=1} |
First image | ✅ STABLE |
{img=2} |
Second image | ✅ STABLE |
{img=-1} |
Last image | ✅ STABLE |
{img=-2} |
Second to last | ✅ STABLE |
{img=*} |
All images | ✅ STABLE |
{img=regex} |
Images matching alt text pattern | ✅ STABLE |
Examples:
# Replace first image
s/{img=1}//
# Delete first image
s/{img=1}//
# Replace last image
s/{img=-1}//
# Replace by alt text pattern
s/{img=old-logo}//
# Apply to all images
s/{img=*}/{x=400}/dimensions = "{" dimension-list "}"
dimension-list = dimension ( " " dimension )*
dimension = width | height
width = ("width" | "w" | "x") "=" number
height = ("height" | "h" | "y") "=" number
number = DIGIT+
Status: ✅ STABLE — The
{T=}key is the canonical brace-based addressing syntax for tabular data across Google Docs tables and Google Sheets. This is the primary syntax for all table operations.
The {T=} key uses ! as the mode switch: the ! separator (following Excel/Sheets convention) enters cell context. An optional DOC_ID: prefix enables cross-document references.
{T=table!cell}
{T=table!range}
{T=table!row-or-col-op}
{T=[doc:]sheet!cell} # For Sheets
| Component | Meaning | Examples |
|---|---|---|
table |
Table reference (1-indexed, negative for reverse) | 1, -1, * |
doc: |
Document ID (optional, for cross-doc refs) | 1f1W9Wd...: |
sheet |
Sheet tab by name or 0-based index | Sales, 0, Budget |
! |
Table/cell separator | |
cell |
Cell address (Excel-style) | A1, B3 |
range |
Cell range (rectangular) | A1:C3 |
* |
Wildcard (entire table/row/column) | 1!*, 1!1,*, 1!*,2 |
row=/col= |
Row/column operations | row=$+, col=+3 |
# Reference tables by position
s/{T=1!A1}/Name/ # First table, cell A1
s/{T=-1!B2}/Value/ # Last table, cell B2
s/{T=*!1,*}/{b}/ # All tables, entire row 1# Cell in first table
s/{T=1!A1}/{t=Revenue b}/
# Cell by row,col notation (1-indexed)
s/{T=1!2,3}/{t=Data}/
# Rectangular range
s/{T=1!A1:C3}/{b}/
# Entire table (all cells)
s/{T=1!*}/{0}/
# Wildcard: entire row
s/{T=1!1,*}/{b}/ # Bold entire row 1
# Wildcard: entire column
s/{T=1!*,2}/{i}/ # Italicize entire column 2# Append row to first table
s/{T=1!row=$+}//
# Insert row before row 2
s/{T=1!row=+2}//
# Delete row 5
s/{T=1!row=5}//
# Insert column before column 3
s/{T=1!col=+3}//
# Delete last column
s/{T=1!col=-1}//
# Append column at end
s/{T=1!col=$+}//# Create 3×4 table (3 rows, 4 columns)
s/{{TABLE}}/{T=3x4}/
# With header flag
s/{{TABLE}}/{T=3x4:header}/
# Create table in empty document
s/^$/{T=3x4}/# Delete first table
s/{T=1}//
# Delete last table
s/{T=-1}//
# Delete all tables
s/{T=*}//# Merge cells in a table
s/{T=1!A1:C1}/merge/
# Merge a 2x2 block
s/{T=1!2,1:3,2}/merge/# Reference cell in another doc's sheet
s/{T=1f1W9Wd...:Sales!A1}/{t=Updated}/
# Reference named sheet tab
s/{T=Budget!C5}/{t=$$1,234 b c=green}/
# Format entire sheet header row
s/{T=0!1,*}/{b z=#333 c=white}/# Set value + bold + color
s/{T=1!B2}/{t=$$42,000 b c=green}/
# Bold an entire header row
s/{T=1!1,*}/{b z=#333 c=white}/
# Format column as currency
s/{T=1!*,3}/{c=green b}/Special patterns for inserting content at document positions without matching existing text:
| Pattern | Meaning | Status |
|---|---|---|
^$ |
Empty document only | REQUIRED |
^ |
Beginning of document (prepend) | REQUIRED |
$ |
End of document (append) | REQUIRED |
^$— Implementations MUST check that the document body is empty (no non-whitespace content). If the document is not empty, the expression MUST be a no-op.^— Implementations MUST insert the replacement at the beginning of the document body (index 1).$— Implementations MUST insert the replacement at the end of the document body.
# Insert text into an empty document
s/^$/Hello world/
# Prepend title to any document
s/^/{h=t t=Document Title}\n/
# Append footer
s/$/\nGenerated on 2026-02-17/
# Insert table at start
s/^/{T=3x4}\n/Positional insert MUST support all replacement features (formatting, images, tables, headings, lists, etc.).
The --dry-run (or -n) flag shows what changes would be made without modifying the document:
gog docs sed <doc-id> 's/foo/bar/g' --dry-run
gog docs sed <doc-id> 's/old/new/' -nImplementations MUST display the matches and proposed changes, and MUST NOT modify the document.
The -e (or --expressions) flag MAY be repeated to execute multiple expressions sequentially in a single invocation:
gog docs sed <doc-id> -e '1s/.*/{h=t}Quarterly Report/' -e 's/DRAFT/{b c=red}FINAL/g'The -f flag reads expressions from a file (one per line). Lines starting with # are comments. When no expression argument or -f file is supplied, CLI implementations SHOULD read expressions from stdin (supporting shell pipes and heredocs):
gog docs sed <doc-id> -f transforms.sed
echo 's/foo/{b}bar/' | gog docs sed <doc-id>
gog docs sed <doc-id> <<'EOF'
s/TITLE/{h=t}My Report/
s/DRAFT/{b c=green}FINAL/
EOFtransforms.sed:
# Header formatting
s/TITLE/{h=t}/
s/SUBTITLE/{h=s}/
# Clean up
s/DRAFT//g
d/TODO/
# Add footer
s/$/\nGenerated automatically/-p(paste mode): Inserts raw file or stdin content directly as seed text (useful in seed-then-format workflows).--tab <title-or-id>: Scopes addressing, introspection, and edits to a specific document tab or section.
gog docs sed <doc-id> --tab "Summary" '3,5s/old/new/g'When replacement contains no formatting markers, implementations SHOULD use native regex APIs:
s/colour/color/g # Plain text
s/\bfoo\b/bar/g # Word boundary
s/2023/2024/g # NumericRequired when formatting is present:
s/foo/{b}/g # Brace syntax
s/bar/{u=https://bar.com}/g # Link
s/{{IMG}}// # ImageCharacters with special meaning MUST be escaped with backslash:
| Character | Escape | Context |
|---|---|---|
/ |
\/ |
When used as delimiter |
* |
\* |
Literal asterisk |
[ |
\[ |
Literal bracket |
] |
\] |
Literal bracket |
( |
\( |
Literal paren (in replacement) |
) |
\) |
Literal paren (in replacement) |
$ |
$$ |
Literal dollar sign (in replacement) |
& |
\& |
Literal ampersand (in replacement) |
\ |
\\ |
Literal backslash |
{ |
\{ |
Literal brace (in replacement) |
} |
\} |
Literal brace (in replacement) |
Note: This section describes Markdown shortcuts that serve as a convenience layer. The canonical formatting system is Brace Syntax. Implementations MUST support brace syntax; Markdown shortcuts are RECOMMENDED for standard CommonMark syntax.
For users familiar with Markdown, SEDMAT supports common Markdown formatting syntax as an alternative to brace syntax. These produce identical output.
| Syntax | Brace Equivalent | Effect | Status |
|---|---|---|---|
**text** |
{b t=text} |
Bold | ✅ RECOMMENDED |
*text* |
{i t=text} |
Italic | ✅ RECOMMENDED |
_text_ |
{i t=text} |
Italic | ✅ RECOMMENDED |
***text*** |
{b i t=text} |
Bold + Italic | ✅ RECOMMENDED |
~~text~~ |
{- t=text} |
Strikethrough | ✅ RECOMMENDED |
`text` |
{# t=text} |
Monospace | ✅ RECOMMENDED |
Examples:
# These pairs are equivalent:
s/warning/**warning**/g # Markdown
s/warning/{b}/g # Brace (preferred)
s/emphasis/*emphasis*/g # Markdown
s/emphasis/{i}/g # Brace (preferred)
s/deprecated/~~deprecated~~/g # Markdown
s/deprecated/{-}/g # Brace (preferred)| Syntax | Brace Equivalent | Effect |
|---|---|---|
# text |
{h=1 t=text} |
Heading 1 |
## text |
{h=2 t=text} |
Heading 2 |
### text |
{h=3 t=text} |
Heading 3 |
#### text |
{h=4 t=text} |
Heading 4 |
##### text |
{h=5 t=text} |
Heading 5 |
###### text |
{h=6 t=text} |
Heading 6 |
Examples:
# These pairs are equivalent:
s/TITLE/# My Document/ # Markdown
s/TITLE/{h=1 t=My Document}/ # Brace
s/Introduction/## Introduction/ # Markdown
s/Introduction/{h=2}/ # Brace (preserves text)| Syntax | Effect |
|---|---|
- item |
Bullet list item |
1. item |
Numbered list item |
- nested |
Nested bullet (L1, 2 spaces) |
- nested |
Nested bullet (L2, 4 spaces) |
1. nested |
Nested numbered (L1, 2 spaces) |
1. nested |
Nested numbered (L2, 4 spaces) |
Examples:
# Create a bullet list
s/ITEMS/- First item\n- Second item\n- Third item/
# Numbered list
s/STEPS/1. Step one\n2. Step two\n3. Step three/
# Nested lists
s/OUTLINE/- Top level\n - Nested L1\n - Nested L2/Three or more of -, *, or _ on a line create a horizontal rule:
s/DIVIDER/---/
s/BREAK/***/
s/SEPARATOR/___/Brace equivalent: {+}
Lines prefixed with > create blockquotes (left-indented with grey left border):
s/QUOTE/> This is a blockquote/
s/EPIGRAPH/> To be or not to be\n> That is the question/Triple backtick fences create code blocks (Courier New font, grey background). Language hints after the opening fence are stripped:
s/CODE/```\nfunction hello() {\n console.log("hi");\n}\n```/
s/SNIPPET/```python\nprint("hello")\n```/The [^text] syntax creates native footnotes in the target document:
s/citation/[^See Smith et al., 2024]/
s/note/[^This is a footnote with detailed explanation]/Note: While not part of CommonMark core, footnote syntax (
[^...]) is widely supported in extended Markdown flavors and is RECOMMENDED.
Formats MAY be nested according to Markdown precedence:
# Bold AND italic
s/warning/***warning***/
# Bold with brace underline
s/critical/**{_ t=critical}**/Processing Order:
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#333333', 'primaryTextColor': '#ffffff', 'primaryBorderColor': '#555555', 'lineColor': '#aaaaaa', 'secondaryColor': '#2a2a2a', 'tertiaryColor': '#222222', 'background': '#111111', 'edgeLabelBackground': '#222222' }}}%%
graph LR
TEXT[text] --> B["**bold**"]
B --> I["*italic*"]
I --> FINAL["***text***"]
style TEXT fill:#2a2a2a,color:#ffffff,stroke:#555555
style FINAL fill:#1a4a1a,color:#ffffff,stroke:#2a7a2a
Implementations MUST process nesting from innermost to outermost.
sedmat-line = sedmat-expr / comment
comment = "#" *VCHAR
; --- Container Scopes (v3.7) ---
container-scope = "@" [container-type "="] container-target [":" region-name] ":"
container-op = "@" [container-type "="] container-target ( "d" / "a" delimiter text delimiter / "i" delimiter text delimiter / brace-expr )
container-type = "slide" / "sheet" / "tab" / "page" / "section"
container-target = address / "*" / DQUOTE 1*(%x20-21 / %x23-7E) DQUOTE / 1*(ALPHA / DIGIT / "-" / "_")
region-name = "title" / "sub" / "subtitle" / "body" / "notes" / "header" / "footer" / ("shape=" pos-int)
; --- Addresses (v3.6) ---
address = addr-single / addr-range
addr-single = pos-int / "$"
addr-range = pos-int "," (pos-int / "$") ; "$" MUST NOT be range start; end >= start
pos-int = %x31-39 *DIGIT ; 1-based positive integer
; --- Commands ---
sedmat-expr = container-op
/ [container-scope] ( subst-expr / delete-expr / append-expr / insert-expr / xlat-expr / brace-expr )
subst-expr = [address] "s" delimiter pattern delimiter replacement delimiter [flags]
delete-expr = address "d"
/ [address] "d" delimiter pattern delimiter [regex-flags]
append-expr = address "a" delimiter text delimiter
/ "a" delimiter pattern delimiter text delimiter [regex-flags]
insert-expr = address "i" delimiter text delimiter
/ "i" delimiter pattern delimiter text delimiter [regex-flags]
xlat-expr = "y" delimiter source-chars delimiter dest-chars delimiter
delimiter = "/" / "#" / "|" / %x21-2E / %x3A-40 / %x5B-60 / %x7B-7E
; Any printable ASCII except alphanumeric
pattern = regex-pattern
source-chars = 1*CHAR
dest-chars = 1*CHAR ; Must be same length as source-chars
; --- Flags ---
flags = *( "g" / "i" / "m" / pos-int )
regex-flags = *( "i" / "m" )
; --- Replacement ---
replacement = *( plain-text / brace-expr / format-expr / back-ref / image-expr
/ link-expr / heading-expr / list-expr
/ block-expr / footnote-expr )
; --- Brace Syntax (v3.6) ---
brace-expr = "{" brace-body "}"
brace-body = reset-all / no-reset / brace-flags
reset-all = "0" *( SP brace-flag ) ; {0} or {0 b i}
no-reset = "!0" *( SP brace-flag ) ; {!0 b} additive mode (opt out of implicit reset)
brace-flags = brace-flag *( SP brace-flag )
brace-flag = "!0" / bool-flag / neg-flag / value-flag / break-flag
/ comment-flag / bookmark-flag / table-flag / image-flag
/ toc-flag / check-flag
bool-flag = bool-key ["=" val-value] ; {b} or {b=text} for inline scoping
bool-key = "b" / "bold" / "i" / "italic" / "_" / "underline"
/ "-" / "strike" / "#" / "code" / "^" / "sup"
/ "," / "sub" / "w" / "smallcaps"
neg-flag = "!" bool-key ; Negation (prefix only)
check-flag = "check" ["=" ("y" / "n")] ; Tri-state checkbox
toc-flag = "toc" ["=" DIGIT+] ; Table of contents with optional depth
value-flag = val-key "=" val-value
val-key = "t" / "text" / "c" / "color" / "z" / "bg"
/ "f" / "font" / "s" / "size" / "u" / "url"
/ "l" / "leading" / "a" / "align" / "o" / "opacity"
/ "n" / "indent" / "k" / "kerning" / "x" / "width"
/ "y" / "height" / "p" / "spacing" / "h" / "heading"
/ "e" / "effect" / "cols"
val-value = 1*(%x21-7E) ; Non-space printable ASCII
spacing-value = DIGIT+ ["," DIGIT+] ; Single value or above,below
break-flag = "+" ["=" break-type]
break-type = "p" / "c" / "s" ; page / column / section
comment-flag = DQUOTE "=" comment-text
comment-text = 1*(%x20-7E) ; Printable ASCII incl. space
bookmark-flag = "@" "=" bookmark-name
bookmark-name = 1*(%x21-7E)
; --- Table Brace Syntax (v3.1) ---
table-flag = "T" "=" table-spec
table-spec = table-create / table-ref-spec
table-create = DIGIT+ "x" DIGIT+ [":header"] ; {T=3x4}, {T=3x4:header}
table-ref-spec = table-index ["!" cell-spec]
table-index = ["-"] DIGIT+ / "*" ; 1, -1, *
cell-spec = excel-cell / row-col-cell / cell-range / row-op / col-op / wildcard
excel-cell = ALPHA+ DIGIT+ ; A1, B12
row-col-cell = (DIGIT+ / "*") "," (DIGIT+ / "*") ; 1,2 or 1,* or *,2
cell-range = (excel-cell / row-col-cell) ":" (excel-cell / row-col-cell)
row-op = "row" "=" ("+" DIGIT+ / "$+" / ["-"] DIGIT+)
col-op = "col" "=" ("+" DIGIT+ / "$+" / ["-"] DIGIT+)
wildcard = "*"
; --- Image Brace Syntax (v3.1) ---
image-flag = "img" "=" image-spec
image-spec = ["-"] DIGIT+ / "*" / regex-pattern ; 1, -1, *, pattern
heading-value = "t" / "s" / "0" / "1" / "2" / "3" / "4" / "5" / "6"
; t=TITLE, s=SUBTITLE, 0=NORMAL_TEXT, 1-6=HEADING_1-6
uri-value = standard-uri / chip-uri / bookmark-uri
standard-uri = scheme ":" *(%x21-7E)
scheme = "https" / "http" / "mailto" / "tel" / "geo"
/ "sms" / "webcal" / "file"
chip-uri = "chip://" chip-type "/" *(%x21-7E)
chip-type = "person" / "date" / "file" / "place"
/ "dropdown" / "chart" / "bookmark"
bookmark-uri = "#" bookmark-name ; {u=#name}
color-value = "#" 6HEXDIG / color-name ; #RRGGBB or named
color-name = "black" / "white" / "red" / "green" / "blue"
/ "yellow" / "cyan" / "magenta" / "orange" / "purple"
/ "pink" / "brown" / "gray" / "grey" / "lightgray"
/ "darkgray" / "navy" / "teal"
; --- Markdown Formatting (convenience layer) ---
format-expr = bold / italic / bold-italic / strike / mono
bold = "**" content "**"
italic = "*" content "*" / "_" content "_"
bold-italic = "***" content "***"
strike = "~~" content "~~"
mono = "`" content "`"
footnote-expr = "[^" content "]"
heading-expr = 1*6("#") SP content ; # through ######
list-expr = bullet-item / numbered-item
bullet-item = [indent] "- " content
numbered-item = [indent] DIGIT+ ". " content
indent = 2*SP ; 2 spaces per nesting level
block-expr = horiz-rule / blockquote / code-block
horiz-rule = "---" / "***" / "___"
blockquote = "> " content
code-block = "```" [lang-hint] LF content LF "```"
back-ref = "$" DIGIT / "\" DIGIT / "&" / "$$"
link-expr = "[" link-text "](" url [SP "\"" title "\""] ")"
/ "<" url ">"
image-expr = image-insert / image-brace-ref
image-insert = "![" [alt-text] "](" url ")" [dimensions]
image-brace-ref = "{" "img" "=" image-spec "}"
dimensions = "{" *( dim-spec SP ) "}"
dim-spec = ("width" | "w" | "x") "=" NUMBER
/ ("height" | "h" | "y") "=" NUMBER
positional-pat = "^$" / "^" / "$"- Basic
s/pattern/replacement/ands/pattern/replacement/g - Flags:
g,i(case-insensitive),m(multiline),N(nth occurrence) - Brace syntax: boolean flags (
{b},{i},{_},{-},{#},{^},{,},{w}), negation ({!b}) - Brace syntax: flexible placement (
{b}text,text{b},{c=red}text{b}) and inline scoping ({b=text},{^=text},{,=text}, etc.) - Brace syntax: value flags (
{c=},{z=},{f=},{s=},{u=},{t=},{l=},{a=},{o=},{n=},{k=},{x=},{y=},{p=},{h=},{e=}) - Brace syntax: reset (
{0}) - Brace syntax: implicit
t=$0behavior - Brace syntax:
{h}defaults to HEADING_1,{h=0}for NORMAL_TEXT - Brace syntax: named colors (RECOMMENDED) and hex colors (REQUIRED)
- Back-references:
$1-$9,$0,&,$$escaping - Links:
[text](url),<url>,{u=url}
- All Level 1 features
- Image insertion:
,(standard markdown) - Image dimensions:
{x=N},{y=N},{x=N y=M} - Image brace references:
{img=n},{img=-n},{img=*},{img=regex} - Brace syntax: heading shorthands (
{h=t},{h=s},{h=1}–{h=6},{h=0}) - Brace syntax: paragraph spacing (
{p=N},{p=N,M})
- All Level 2 features
- Positional insert:
^$,^,$ - Table brace syntax:
{T=RxC},{T=RxC:header}(creation) - Table brace references:
{T=1},{T=-1},{T=*}(reference/deletion) - Table brace cell access:
{T=1!A1},{T=1!R,C}, wildcards ({T=1!1,*},{T=1!*,2},{T=1!*}) - Table brace rectangular ranges:
{T=1!A1:C3} - Table brace row/column operations:
{T=1!row=+N},{T=1!col=$+}, etc. - Table merge:
{T=1!A1:C3}/merge/ - Brace syntax: breaks (
{+},{+=p},{+=c},{+=s}) - Brace syntax: columns (
{cols=N}) - Brace syntax: checkboxes (
{check},{check=n},{check=y}) - Brace syntax: table of contents (
{toc},{toc=N}) - Brace syntax: comments (
{"=text}) - Brace syntax: bookmarks (
{@=name},{u=#name})
- All Level 3 features
- Paragraph addressing:
N,N,M,$,N,$across top-level elements (paragraph,table,toc) - Addressed forms:
Nd,N,Md,$d,N,$d,N,Md/pat/,Ns///,N,Ms///,Na/text/,Ni/text/,$a/text/ - Address validation & safe terminal deletion semantics
- Delete command:
d/pattern/[flags] - Append command:
a/pattern/text/[flags] - Insert command:
i/pattern/text/[flags] - Transliterate command:
y/source/dest/ - Dry-run mode:
--dry-run/-n - Batch processing:
-f file.sed,-e <expr>, stdin piping - Document introspection (
structure,cat -N) and multi-tab scoping (--tab) (RECOMMENDED)
- All Level 4 features
- URI schemes: standard (
https:,mailto:,tel:,geo:,sms:,webcal:,file:) - URI schemes:
chip://smart chips (person, date, file, place, dropdown, chart, bookmark) - Charts:
chip://chart/references
- All Level 5 features
- Markdown shortcuts:
**bold**,*italic*,`mono`,~~strike~~ - Markdown headings:
#through###### - Markdown lists:
- bullet,1. numbered, nested - Markdown blocks:
---(horizontal rule),> quote,code blocks - Footnotes:
[^text]
| Feature | Status | Requirement Level |
|---|---|---|
Basic s/// syntax |
✅ Stable | REQUIRED |
Global flag g |
✅ Stable | REQUIRED |
Case-insensitive flag i |
✅ Stable | REQUIRED |
Nth occurrence flag N |
✅ Stable | REQUIRED |
Multiline flag m |
✅ Stable | REQUIRED |
Paragraph addressing (N, N,M, $, N,$) |
✅ Stable | REQUIRED |
Addressed commands (Nd, Ns///, Na/text/, Ni/text/) |
✅ Stable | REQUIRED |
Document introspection (structure, cat -N) |
✅ Stable | RECOMMENDED |
Multi-tab / section scoping (--tab) |
✅ Stable | RECOMMENDED |
| Brace syntax: basic parsing | ✅ Stable | REQUIRED |
Brace syntax: flexible placement ({b}text, text{b}, {c=red}text{b}) |
✅ Stable | REQUIRED |
Brace syntax: boolean flags (b, i, _, -, #, ^, ,, w) |
✅ Stable | REQUIRED |
Brace syntax: inline scoping ({b=text}, {^=text}, etc.) |
✅ Stable | REQUIRED |
Brace syntax: negation (!b) |
✅ Stable | REQUIRED |
Brace syntax: value flags (c=, z=, f=, s=, etc.) |
✅ Stable | REQUIRED |
Brace syntax: text flag (t=) with implicit $0 |
✅ Stable | REQUIRED |
Brace syntax: reset ({0}) |
✅ Stable | REQUIRED |
| Brace syntax: named colors | ✅ Stable | RECOMMENDED |
Brace syntax: hex colors (#RRGGBB) |
✅ Stable | REQUIRED |
Brace syntax: heading shorthands (h=t, h=1, {h} → HEADING_1) |
✅ Stable | REQUIRED |
Brace syntax: {h=0} for NORMAL_TEXT |
✅ Stable | REQUIRED |
Brace syntax: paragraph spacing (p=N, p=N,M) |
✅ Stable | REQUIRED |
Brace syntax: breaks ({+}, {+=p}, etc.) |
✅ Stable | REQUIRED |
Brace syntax: columns ({cols=N}) |
✅ Stable | REQUIRED |
Brace syntax: checkboxes ({check}, {check=n}, {check=y}) |
✅ Stable | REQUIRED |
Brace syntax: table of contents ({toc}, {toc=N}) |
✅ Stable | REQUIRED |
Brace syntax: comments ({"=text}) |
✅ Stable | REQUIRED |
Brace syntax: bookmarks ({@=name}) |
✅ Stable | REQUIRED |
Brace syntax: URL/link (u=) |
✅ Stable | REQUIRED |
Brace syntax: chip:// smart chips |
✅ Stable | REQUIRED |
Brace syntax: superscript/subscript ({^}, {,}) |
✅ Stable | REQUIRED |
Brace syntax: table addressing ({T=}) |
✅ Stable | REQUIRED |
Brace syntax: image references ({img=}) |
✅ Stable | REQUIRED |
Back-references $1-$9, $0, & |
✅ Stable | REQUIRED |
Dollar sign escaping $$ |
✅ Stable | REQUIRED |
Links [text](url), {u=url} |
✅ Stable | REQUIRED |
Auto-links <url> |
✅ Stable | REQUIRED |
Image insert ,  |
✅ Stable | REQUIRED |
Image dimensions {x=N}, {x=N y=M} |
✅ Stable | REQUIRED |
| Native regex mode | ✅ Stable | RECOMMENDED |
Positional insert (^$, ^, $) |
✅ Stable | REQUIRED |
Delete command d/pattern/ & [addr]d |
✅ Stable | REQUIRED |
Append command a/pattern/text/ & [addr]a/text/ |
✅ Stable | REQUIRED |
Insert command i/pattern/text/ & [addr]i/text/ |
✅ Stable | REQUIRED |
Transliterate command y/src/dst/ |
✅ Stable | REQUIRED |
Table creation ({T=RxC}) |
✅ Stable | REQUIRED |
Table deletion ({T=N}, {T=*}) |
✅ Stable | REQUIRED |
Cell references ({T=1!A1}, {T=1!R,C}) |
✅ Stable | REQUIRED |
Cell wildcards ({T=1!1,*}, {T=1!*,2}, {T=1!*}) |
✅ Stable | REQUIRED |
Rectangular ranges ({T=1!A1:C3}) |
✅ Stable | REQUIRED |
Row operations ({T=1!row=+N}, {T=1!row=$+}) |
✅ Stable | REQUIRED |
Column operations ({T=1!col=+N}, {T=1!col=$+}) |
✅ Stable | REQUIRED |
Table merge ({T=1!r1,c1:r2,c2}/merge/) |
✅ Stable | REQUIRED |
Dry-run mode (--dry-run, -n) |
✅ Stable | REQUIRED |
Batch processing (-f file.sed, -e, stdin) |
✅ Stable | REQUIRED |
Markdown formatting (**, *, `, ~~) |
✅ Stable | RECOMMENDED |
Markdown headings (# through ######) |
✅ Stable | RECOMMENDED |
Markdown lists (-, 1., nested) |
✅ Stable | RECOMMENDED |
| Markdown blocks (rules, quotes, code) | ✅ Stable | RECOMMENDED |
Footnotes [^text] |
✅ Stable | RECOMMENDED |
| Table cell styling | 🔮 Proposed | OPTIONAL |
| @ mentions | 🔮 Proposed | OPTIONAL |
- openclaw/gogcli (Go) — Reference CLI & Google Docs implementation (
gog docs sed,gog docs structure,gog docs cat -N,internal/docssed) visionik/libsedmat-go(Go, in progress) — Standalone target-agnostic Go library extracted fromgogcli@voxio/sedmat(TypeScript) — Target-agnostic TypeScript parser & OOXML WordprocessingML (libMW) executor
# Replace placeholders with content
s/{{NAME}}/Acme Corp/
s/{{DATE}}/2026-02-17/
s/{{LOGO}}/{x=200}/
s/{{SIGNATURE}}/{u=mailto:john@acme.com t=John Doe}/# Build a structured document
s/^$/{h=t t=Quarterly Report}/
a/Quarterly Report/{h=2 t=Executive Summary}/
a/Executive Summary/The company performed well this quarter./
a/performed well/{h=2 t=Financial Results}/
a/Financial Results/{T=3x3}/
s/{T=1!A1}/Metric/
s/{T=1!B1}/Q3/
s/{T=1!C1}/Q4/
s/{T=1!A2}/Revenue/
s/{T=1!B2}/$$10M/
s/{T=1!C2}/$$12M/
s/{T=1!A3}/Growth/
s/{T=1!B3}/15%/
s/{T=1!C3}/20%/
s/{T=1!1,*}/{b}/
s/$/\n{+}\n> Report generated automatically.\n[^Internal use only.]/cleanup.sed:
# Header formatting
s/TITLE/{h=t}/
s/SUBTITLE/{h=s}/
# Clean up
s/DRAFT//g
d/TODO/
# Style important terms
s/([A-Z]{3,})/{b t=$1}/g
# Add header
s/^/{h=t t=Final Report}\n/gog docs sed -f cleanup.sed <doc-id># Create and populate a pricing table
s/{{PRICING}}/{T=4x3}/
s/{T=1!A1}/{b t=Plan}/
s/{T=1!B1}/{b t=Monthly}/
s/{T=1!C1}/{b t=Annual}/
s/{T=1!1,*}/{b}/
s/{T=1!A2}/Basic/
s/{T=1!A3}/Pro/
s/{T=1!A4}/Enterprise/
# Merge header cells
s/{T=1!1,1:1,3}/merge/
# Add a row
s/{T=1!row=$+}//
s/{T=1!A5}/Custom/# Add person chips for team mentions
s/assigned to viz/{u=chip://person/viz@example.com t=@viz}/g
s/deadline/{u=chip://date/2026-03-15 t=March 15, 2026}/g
# Add project links
s/project doc/{u=chip://file/DOC_ID t=Project Documentation}/g
# Add status dropdown
s/STATUS/{u=chip://dropdown/Draft|Review|Done t=Draft}/g# Chemistry formulas
s/H2O/H{,=2}O/g
s/CO2/CO{,=2}/g
s/H2SO4/H{,=2}SO{,=4}/g
s/NaHCO3/NaHCO{,=3}/g
# Physics equations
s/E=mc2/E=mc{^=2}/g
s/F=ma/F=ma/g
s/v2=u2\+2as/v{^=2}=u{^=2}+2as/g
# Math expressions
s/x2\+y2=r2/x{^=2}+y{^=2}=r{^=2}/g
s/an=a1\+\(n-1\)d/a{,=n}=a{,=1}+(n-1)d/g# Title in single column
s/^/{h=t t=Monthly Newsletter}\n/
# Switch to 2-column layout for articles
s/ARTICLES_START/{+=s cols=2 h=2 t=Feature Articles}/g
# Column break between major articles
s/ARTICLE_BREAK/{+=c}/g
# Sidebar in narrower 3-column layout
s/SIDEBAR_START/{+=s cols=3 h=3 t=Quick Updates}/g
# Back to single column for footer/contact
s/CONTACT_US/{+=s cols=1 h=2 t=Contact Us}/g# Convert markdown-style checkboxes
s/\[ \]/{check=n}/g
s/\[x\]/{check=y}/g
# Create task list from placeholders
s/TODO: (.+)/{check=n t=$1}/g
s/DONE: (.+)/{check=y t=$1}/g
# Styled checklist items
s/ACTION: (.+)/{check=n b c=red t=$1}/g# Insert TOC after title
s/^/{h=t t=User Guide}\n{toc=3}\n/
# Or replace placeholder
s/{{TABLE_OF_CONTENTS}}/{toc}/
# Depth-limited TOC
s/{{TOC}}/{toc=2}/ # Only h1 and h2Implementations MUST handle errors gracefully:
| Error | Behavior |
|---|---|
| Invalid regex | MUST report error, MUST NOT modify document |
| Invalid or out-of-range paragraph address | MUST report error (including element count when out of range), MUST NOT modify document |
| Address without command or reversed range | MUST report parse error, MUST NOT modify document |
| Unmatched delimiter | MUST report error |
| Invalid brace syntax | SHOULD report warning, MAY attempt recovery |
| Invalid image reference | SHOULD report warning, MAY skip |
| Invalid table reference | SHOULD report warning, MAY skip |
Mismatched y/// lengths |
MUST report error |
| Circular reference | MUST detect and reject |
Invalid chip:// scheme |
SHOULD report warning, MAY skip |
- URL Validation: Implementations SHOULD validate URLs in link and image expressions
- Injection Prevention: Pattern and replacement MUST be treated as data, not executable code
- Resource Limits: Implementations SHOULD limit regex complexity to prevent ReDoS attacks
- Sanitization: Implementations operating on shared documents SHOULD sanitize output
- Smart Chip Validation: Implementations SHOULD validate
chip://URIs before insertion
Note: The following features are under consideration for future versions but are not part of SEDMAT 3.6.
Page-level settings via !^!{key=value} syntax:
!^!{margin=1in size=letter orientation=portrait}
!^!{header=Company Name}
!^!{footer=Page {{page}} of {{pages}}}This feature is deferred pending implementation experience.
- RFC 2119 - Key words for use in RFCs
- CommonMark Spec - Markdown formatting reference
- POSIX Extended Regular Expressions
- sed(1) man page - GNU sed reference
┌──────────────────────────────────────────────────────────────────┐
│ SEDMAT 3.7 Quick Reference │
├──────────────────────────────────────────────────────────────────┤
│ CONTAINER SCOPES (@ — Slides, Sheets, Tabs, Pages, Headers) v3.7 │
│ @2:s/old/new/g Edit inside container 2 │
│ @2,5:s/old/new/g @*:... Range or all containers │
│ @"Summary":3d @slide=2:... By name or typed assertion │
│ @2:title:s/.../ @2:notes:a/... Named sub-region / speaker notes │
│ @header:s/.../ @footer:s/.../ Word/Docs header & footer │
│ @3d @$a/{layout=two-col}Hi/ Delete/append/insert container │
│ @3{move=1} @2{dup} @4{hide} Reorder, duplicate, hide │
├──────────────────────────────────────────────────────────────────┤
│ PARAGRAPH ADDRESSING (1-based: paragraph, table, toc) ✅ STABLE │
│ N / N,M / $ / N,$ Single, range, last, to-end │
│ 5d 3,7d $d 3,$d Delete addressed element(s) │
│ 3,7d/pattern/ Delete addressed matching regex │
│ 5s/pat/rep/[flags] Substitute within element 5 │
│ 5a/text/ $a/text/ Append after addressed element │
│ 3i/text/ 1i/text/ Insert before addressed element │
│ structure / cat -N List numbered elements [1]..[N] │
├──────────────────────────────────────────────────────────────────┤
│ COMMANDS │
│ [addr]s/pattern/replacement/[flags] Substitute │
│ d/pattern/[flags] / [addr]d Delete paragraphs │
│ a/pattern/text/ / [addr]a/text/ Append after paragraphs │
│ i/pattern/text/ / [addr]i/text/ Insert before paragraphs │
│ y/source/dest/ Transliterate characters │
├──────────────────────────────────────────────────────────────────┤
│ FLAGS │
│ g Global (all matches) i Case-insensitive │
│ m Multiline mode N Nth occurrence (1..N) │
│ (none) First match only gi/gm Combine flags │
├──────────────────────────────────────────────────────────────────┤
│ BRACE SYNTAX {flags} — CANONICAL FORMATTING ✅ STABLE │
│ Placement: {b}text | text{b} | {c=red}text{b} | {b} ($0) │
│ │
│ BOOLEAN FLAGS (presence activates): │
│ {b} Bold {i} Italic │
│ {_} Underline {-} Strikethrough │
│ {#} Code/mono {^} Superscript │
│ {,} Subscript {w} Small caps │
│ {!b} Negate bold {b i _} Combine flags │
│ │
│ CHECKBOXES (tri-state): │
│ {check} Unchecked ☐ {check=n} Unchecked ☐ │
│ {check=y} Checked ☑ {check=n b} Checkbox + bold │
│ │
│ INLINE SCOPING (apply style to part of replacement): │
│ {b=text} Bold just "text" {i=text} Italic "text" │
│ {^=text} Superscript "text" {,=text} Subscript "text"│
│ H{,=2}O → H₂O E=mc{^=2} → E=mc² {b=Warning}: msg │
│ │
│ VALUE FLAGS (key=value): │
│ {t=text} Replacement text (default: $0 = matched text) │
│ {c=red} Color {z=yellow} Background │
│ {c=#FF0000} Color (hex) {z=#FFFF00} Background (hex) │
│ {f=Roboto} Font {s=14} Size (pt) │
│ {u=URL} Link {u=#name} Bookmark link │
│ {h=1} Heading 1 {h=t} Title │
│ {h=s} Subtitle {h} Heading 1 (default) │
│ {h=0} Normal text {cols=N} Section columns │
│ {p=12} Spacing 12pt {p=12,6} 12pt above, 6pt below │
│ │
│ NAMED COLORS: │
│ black white red green blue yellow cyan magenta │
│ orange purple pink brown gray/grey lightgray darkgray navy teal │
│ │
│ IMPLICIT t= RULE: │
│ {b} expands to {b t=$0} — matched text is preserved │
│ │
│ RESET / ADDITIVE: │
│ {0} Reset ALL {0 b} Reset + bold │
│ {!0} Additive mode {!0 c=red} Layer flags (no reset) │
│ │
│ BREAKS: │
│ {+} Horiz rule {+=p} Page break │
│ {+=c} Column break {+=s} Section break │
│ │
│ COLUMNS (structural — targets containing section): │
│ {cols=2} 2-column section {cols=1} Single column │
│ {+=s cols=2} Section break + 2 cols {+=c} Column break │
│ │
│ TABLE OF CONTENTS: │
│ {toc} Full TOC {toc=2} TOC depth 2 (h1-h2 only) │
│ │
│ SUPERSCRIPT/SUBSCRIPT: │
│ {^} Whole sup {,} Whole sub │
│ {^=text} Sup inline {,=text} Sub inline │
│ H{,=2}O x{^=2}+y{^=2} CO{,=2} E=mc{^=2} │
│ │
│ COMMENTS & BOOKMARKS: │
│ {"=text} Comment {@=name} Bookmark anchor │
│ {u=#name} Link to bookmark │
│ │
│ SMART CHIPS: │
│ {u=chip://person/email} Person chip │
│ {u=chip://date/YYYY-MM-DD} Date chip │
│ {u=chip://file/ID} File chip │
│ {u=chip://dropdown/a|b|c} Dropdown chip │
│ {u=chip://chart/ID/0} Chart embed │
├──────────────────────────────────────────────────────────────────┤
│ TABLES — BRACE SYNTAX {T=} ✅ STABLE │
│ {T=3x4} Create 3-row, 4-col table │
│ {T=3x4:header} Create with header │
│ {T=1}, {T=-1}, {T=*} Table reference / delete │
│ {T=1!A1} {T=1!1,2} Cell reference │
│ {T=1!1,*} {T=1!*,2} Row/column wildcard │
│ {T=1!*} Entire table │
│ {T=1!A1:C3} Rectangular range │
│ {T=1!row=+2} {T=1!row=$+} Insert/append row │
│ {T=1!col=+2} {T=1!col=$+} Insert/append column │
│ {T=1!A1:C3}/merge/ Merge cell range │
├──────────────────────────────────────────────────────────────────┤
│ IMAGES ✅ STABLE │
│  Insert image (standard markdown) │
│  Insert (no alt text) │
│ {x=N} or {y=N} Set dimensions │
│ {img=1}, {img=-1} Reference by position │
│ {img=*} All images │
│ {img=regex} Match by alt text │
├──────────────────────────────────────────────────────────────────┤
│ MARKDOWN SHORTCUTS (convenience layer) │
│ **text** Bold *text* Italic │
│ ~~text~~ Strike `text` Monospace │
│ ***text*** Bold+Italic │
│ # text Heading 1 ## text Heading 2, etc. │
│ - item Bullet list 1. item Numbered list │
│ --- Horiz rule > text Blockquote │
│ ```code``` Code block [^text] Footnote │
├──────────────────────────────────────────────────────────────────┤
│ BACK-REFERENCES │
│ $0 or & Entire match $1-$9 Capture groups│
│ $$ Literal $ \& Literal & │
├──────────────────────────────────────────────────────────────────┤
│ LINKS │
│ [text](url) Hyperlink │
│ {u=url} Brace syntax link │
├──────────────────────────────────────────────────────────────────┤
│ POSITIONAL INSERT │
│ s/^$/text/ Insert into empty document │
│ s/^/text/ Prepend to document │
│ s/$/text/ Append to document │
├──────────────────────────────────────────────────────────────────┤
│ CLI OPTIONS │
│ --dry-run / -n Preview changes (no modify) │
│ -e <expr> Inline expression (repeatable) │
│ -f file.sed Batch expressions from file │
│ -p Paste mode (insert file as seed text) │
│ --tab <title-or-id> Scope addressing/edits to tab/section │
└──────────────────────────────────────────────────────────────────┘
New Features:
- Format-Agnostic Container Scopes (
@):- Unified container addressing across PowerPoint Slides, Excel/Sheets Worksheets, Google Docs Tabs, Word Sections/Headers/Footers, and PDF Pages without single-letter collisions (
@2:,@2,5:,@$:,@*:,@"Summary":,@header:) - Optional typed container assertions (
@slide=2:,@sheet=Budget:,@tab=Summary:,@page=4:) - Named sub-region scoping (
@2:title:,@2:sub:,@2:body:,@2:notes:,@1:header:,@1:footer:,@2:shape=2:) - Container-level structural commands (
@3d,@2,4d,@$a/.../,@2i/.../,@3{move=1},@2{dup},@4{hide})
- Unified container addressing across PowerPoint Slides, Excel/Sheets Worksheets, Google Docs Tabs, Word Sections/Headers/Footers, and PDF Pages without single-letter collisions (
- Slide & Shape Brace Flags:
- Added
{layout=},{zone=},{shape=},{fill=},{stroke=},{notes=},{transition=},{move=},{dup},{hide} - Reference implementation:
@voxio/sedmat+@voxio/libmpp(PowerPoint.pptx)
- Added
New Features (incorporated from openclaw/gogcli reference implementation):
- Classic
sedParagraph Addressing (N,N,M,$,N,$):- 1-based addressing across top-level document elements (
paragraph,table,toc) - Addressed commands:
Nd,N,Md,$d,N,$d,N,Md/pattern/[flags],[addr]s/pat/rep/[flags],[addr]a/text/,[addr]i/text/(single-argument append/insert without a search pattern) - Strict validation rules (
$prohibited as range start, reversed ranges rejected, out-of-range indices report element count, address-without-command rejected) - Safe terminal deletion semantics for contiguous
N,$d, single$d, and sole-element1dpreserving trailing document sentinels
- 1-based addressing across top-level document elements (
- Document Introspection Conventions (RECOMMENDED):
structurelisting andcat -N([1],[2], ...) numbered output aligned 1:1 with SEDMAT paragraph addresses
- Multi-Tab / Section Scoping (
--tab):- Scope introspection and addressed edits to a named/ID'd tab or section
- Case-Insensitive Flag (
i) & General Positive Nth Occurrence (N):iflag ((?i)) supported ons,d,a,icommands alongsidem,g, and arbitrary positive integerN
- Additive Mode (
{!0}):- Opts out of implicit formatting reset so co-occurring flags layer additively onto existing styles (
{!0 c=red}), complementing explicit full reset{0}
- Opts out of implicit formatting reset so co-occurring flags layer additively onto existing styles (
- Flexible Brace Placement:
- Documented canonical braces before text (
{b}hello), after text (hello{b}), and surrounding text ({c=red}warning{b}), in addition to standalone{b}(t=$0) and inline{b=text}
- Documented canonical braces before text (
- CLI Modes:
- Documented
-erepeatable inline expressions, stdin/heredoc piping,-ppaste mode, and--tabscoping
- Documented
- Spec Updates:
- Updated Expression Anatomy & Processing Model diagrams, ABNF grammar (
address,addr-single,addr-range,regex-flags), Conformance Levels, Implementation Status (with Known Implementations), Error Handling, and Quick Reference Card
- Updated Expression Anatomy & Processing Model diagrams, ABNF grammar (
New Features:
- Checkboxes (
{check}): Native checklist support with tri-state semantics{check}or{check=n}— unchecked checkbox{check=y}— checked checkbox- Can combine with other flags:
{check=n b}
- Table of Contents (
{toc}): Auto-generated TOC from document headings{toc}— full table of contents{toc=N}— TOC with max depth N- Implementations SHOULD auto-link entries to headings
- Named Colors: Standard 18-color palette for
c=andz=flags- black, white, red, green, blue, yellow, cyan, magenta
- orange, purple, pink, brown, gray/grey, lightgray, darkgray, navy, teal
- Hex (
#RRGGBB) REQUIRED; named colors RECOMMENDED
- Paragraph Spacing (
{p=}): Clarified spacing syntax{p=12}— 12pt above and below{p=12,6}— 12pt above, 6pt below{p}bare — reset to default
Documentation:
- Added sections: Checkboxes, Table of Contents, Named Colors, Paragraph Spacing
- Trimmed Columns section from ~112 to ~60 lines
- Consolidated changelog (v3.0–v3.4 merged into v3.5)
- Updated ABNF with
check-flag,toc-flag,color-value,spacing-value - Updated Conformance Levels, Implementation Status, Quick Reference Card
Includes all features from v3.0–v3.4:
- Brace Syntax as canonical formatting system (v3.0)
- Unified
{T=}table addressing and{img=}image references (v3.1) - Inline scoping for boolean flags (
{b=text},{^=text},{,=text}) (v3.3) - Column support (
{cols=N}) as structural flag (v3.4) - Structural vs text flag distinction
chip://smart chips for Google Docs- All extended commands (
d/,a/,i/,y/)
- New commands:
d/pattern/(delete),a/pattern/text/(append),i/pattern/text/(insert),y/source/dest/(transliterate) - New flags:
n(nth occurrence, e.g.s/foo/bar/2),m(multiline mode) - Heading styles:
#through######→ native Heading 1–6 - Paragraph styles:
- bullet,1. numbered, nested lists with indentation - Horizontal rules:
---,***,___→ grey bottom border - Blockquotes:
> text→ left-indented with grey left border - Code blocks: Triple backtick fences → Courier New + grey background
- Superscript/subscript:
^{text},~{text} - Footnotes:
[^text]→ native document footnotes - Pipe tables: Markdown pipe syntax parsed into native tables
- Table merge:
s/|N|[r1,c1:r2,c2]/merge/for cell merging - Dollar sign escaping:
$$→ literal$in replacements - Whole-match backreference:
&for entire match,\&for literal ampersand - Dry-run mode:
--dry-run/-nflag for previewing changes - Batch processing:
-f file.sedfor reading expressions from files - Reference implementation: gogcli
gog docs sed
- Positional insert: Added
^$,^,$patterns for document-level insertion - Table creation: Promoted to STABLE —
|RxC|and|RxC:header|syntax - Table deletion: Added
s/|N|//,s/|-N|//,s/|*|// - Cell wildcards: Added
[1,*],[*,2],[*,*] - Row operations: Added
[row:N],[row:+N],[row:$+] - Column operations: Added
[col:N],[col:+N],[col:$+] - Reference implementation: gogcli
gog docs sed
- Initial specification
- Core syntax defined
- Text formatting standardized
- Image operations specified
- Table operations proposed
- Conformance levels established