Blocks
Blocks
Section titled “Blocks”Blocks are named regions within a document. They make sections independently addressable — a block can be read or replaced without loading the full document.
Syntax
Section titled “Syntax”<!-- #block_id -->Content of the block.Multiple lines allowed.- Opening marker:
<!-- #id --> - Closing marker:
<!-- /id --> - The ID in the opening and closing markers MUST match.
- Markers MUST each be on their own line.
ID rules
Section titled “ID rules”Block IDs MUST follow these rules:
| Rule | Valid | Invalid |
|---|---|---|
| Lowercase letters | summary | Summary |
| Numbers allowed | section2 | — |
| Hyphens allowed | quick-start | quick_start |
| Must start with a letter | intro | 2section |
| No spaces | action-items | action items |
Pattern: [a-z][a-z0-9-]*
Uniqueness
Section titled “Uniqueness”Block IDs MUST be unique within a document. Duplicate IDs are an error.
<!-- #intro -->First intro.<!-- #intro --> ← ERROR: duplicate IDSecond intro.<!-- /intro -->Nesting
Section titled “Nesting”Blocks MAY be nested. Each block MUST have a unique ID regardless of nesting depth.
<!-- #report --># Quarterly Report
<!-- #summary -->Revenue grew 15%.<!-- /summary -->
<!-- #details -->Detailed breakdown follows.<!-- /details -->
<!-- /report -->Valid references: #report, #summary, #details.
Nested blocks are independently addressable — requesting #summary
returns only the summary content, not the full report.
Empty blocks
Section titled “Empty blocks”A block with no content between markers is valid.
<!-- #placeholder -->Block markers in CommonMark
Section titled “Block markers in CommonMark”Block markers are standard HTML comments. In any CommonMark viewer:
- They are invisible (HTML comments are not rendered)
- They do not affect the surrounding content
- The document reads as normal Markdown
This is how SFMD achieves block addressing without breaking CommonMark compatibility.
Addressing
Section titled “Addressing”Blocks are addressed using the fragment syntax:
document.md#block_idWhen a block is requested:
- Only the content between the opening and closing markers is returned
- The markers themselves are not included in the extracted content
- Content outside the block is not included
Rules summary
Section titled “Rules summary”- Opening marker:
<!-- #id -->on its own line. - Closing marker:
<!-- /id -->on its own line, matching ID. - IDs:
[a-z][a-z0-9-]*— lowercase, no spaces, no underscores. - IDs MUST be unique within a document.
- Nesting is allowed; each nested block is independently addressable.
- Empty blocks are valid.
- Unclosed blocks are an error.
- A block without a matching closing marker is an error.