slateparser

package
v0.52.3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForMentions

func CheckForMentions(text string, objectType string, objectID string, objectName string) map[string]Mention

CheckForMentions parses the Slate formatted text and extracts all user mentions Returns a map where the key is the data-slate-id and the value is the Mention struct

func CheckForNewMentions

func CheckForNewMentions(oldText string, newText string, objectType string, objectID string, objectName string) []string

CheckForNewMentions compares old and new text to identify newly added mentions Takes old text, new text, and returns only the slate IDs that are new

func ExtractMentionedUserIDs

func ExtractMentionedUserIDs(mentions map[string]Mention) []string

ExtractMentionedUserIDs extracts just the user IDs from a mention map. It validates that each UserID is a valid ULID and skips invalid ones.

func GetNewMentions

func GetNewMentions(oldText string, newText string, objectType string, objectID string, objectName string) map[string]Mention

GetNewMentions is a helper that returns the full Mention objects for new mentions. It parses both texts once and returns only mentions that exist in newText but not in oldText.

func IsValidSlateText

func IsValidSlateText(text string) bool

IsValidSlateText checks if the text contains valid Slate formatted content by verifying data-slate-* attributes exist within HTML tags

Types

type Mention

type Mention struct {
	// UserID is the unique identifier of the mentioned user
	UserID string
	// UserDisplayName is the display name shown for the mentioned user
	UserDisplayName string
	// ObjectType is the type of object where the mention was found (e.g., "comment", "task")
	ObjectType string
	// ObjectID is the unique identifier of the object containing the mention
	ObjectID string
	// ObjectName is the human-readable name of the object containing the mention
	ObjectName string
}

Mention represents a user mention extracted from Slate formatted text

Jump to

Keyboard shortcuts

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