Command Palette
Search for a command to run...

Snippets

A snippet is an ordinary fenced code block whose info string carries docref attributes:

```go docref=open-secret:src/api/handler.go#VerifySignature:9c2f1ab3
func (s *Server) VerifySignature(req *Request) error {
    ...
}
```
  • The info string is: language word first (CommonMark convention, so syntax highlighting works everywhere), then space-separated key=value attributes in any order. Unknown keys are preserved.
  • docref= is required. The hash rides on the ref as a :sha suffix, written by the tool; a snippet without one is treated as never-refreshed and is stale by definition. The alias separator is the first colon of a ref, the sha suffix the last, and fragments cannot contain colons, so the two never collide.
  • The body is materialized: the tool writes the extracted anchor contents into the fence and commits them. Readers and renderers see a complete, ordinary code block; nothing resolves at render time.
  • Extraction starts at the beginning of the anchor's first line and removes the common leading indentation, so a method nested in a class materializes flush left with its internal nesting preserved. This is purely presentational; hashing strips all whitespace anyway.
  • The body is owned by the tool. Hand edits are detected (the body no longer hashes to the recorded sha) and overwritten by the next refresh.

A snippet is up-to-date when the anchor's current hash, the recorded :sha, and the hash of the body all agree. Any disagreement makes it stale-snippet; see section 5.