placeholders

package
v0.16.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package placeholders provides a shared vocabulary of placeholder tokens that rules can opt into to treat template content as opaque rather than content violations.

A rule adds a `placeholders:` setting (a list of token names) via the Configurable interface. When checking a node it calls ContainsBodyToken or MaskBodyTokens to decide whether to skip or neutralize the content.

The four initial tokens are:

  • var-token — {identifier} interpolation placeholders
  • heading-question — headings whose text is exactly "?"
  • placeholder-section — headings whose text is exactly "..."
  • cue-frontmatter — CUE constraint expressions in front-matter values

Index

Constants

View Source
const (
	VarToken           = "var-token"
	HeadingQuestion    = "heading-question"
	PlaceholderSection = "placeholder-section"
	CUEFrontmatter     = "cue-frontmatter"
)

Named placeholder tokens.

Variables

This section is empty.

Functions

func ContainsBodyToken

func ContainsBodyToken(text string, tokens []string) bool

ContainsBodyToken reports whether text matches any of the named body tokens. cue-frontmatter is a front-matter–only token and is ignored.

func HasCUEFrontmatter

func HasCUEFrontmatter(tokens []string) bool

HasCUEFrontmatter reports whether cue-frontmatter is in the token list.

func IsAllBodyTokens

func IsAllBodyTokens(text string, tokens []string) bool

IsAllBodyTokens reports whether text (trimmed) consists only of placeholder token patterns, with no other content. Unlike MaskBodyTokens, this strips placeholder patterns to empty rather than replacing with neutral text, so only non-placeholder content remains.

func IsKnown

func IsKnown(name string) bool

IsKnown reports whether name is a recognized token name.

func MaskBodyTokens

func MaskBodyTokens(text string, tokens []string) string

MaskBodyTokens replaces placeholder token patterns in text with neutral content. cue-frontmatter is not a body token and is left unchanged. Whole-text tokens (heading-question, placeholder-section) replace the entire text when they match; substring tokens (var-token) replace each occurrence in place.

func Validate

func Validate(tokens []string) error

Validate returns an error if any token name in the list is unknown.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL