mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[chore/bugfix] Deinterface text.Formatter, allow underscores in hashtags (#2233)
This commit is contained in:
@@ -24,29 +24,25 @@ import (
|
||||
"github.com/superseriousbusiness/gotosocial/internal/gtsmodel"
|
||||
)
|
||||
|
||||
// Formatter wraps some logic and functions for parsing statuses and other text input into nice html.
|
||||
// Each of the member functions returns a struct containing the formatted HTML and any tags, mentions, and
|
||||
// emoji that were found in the text.
|
||||
type Formatter interface {
|
||||
// FromPlain parses an HTML text from a plaintext.
|
||||
FromPlain(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, plain string) *FormatResult
|
||||
// FromPlainNoParagraph parses an HTML text from a plaintext, without wrapping the resulting text in <p> tags.
|
||||
FromPlainNoParagraph(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, plain string) *FormatResult
|
||||
// FromMarkdown parses an HTML text from a markdown-formatted text.
|
||||
FromMarkdown(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, md string) *FormatResult
|
||||
// FromPlainEmojiOnly parses an HTML text from a plaintext, only parsing emojis and not mentions etc.
|
||||
FromPlainEmojiOnly(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, plain string) *FormatResult
|
||||
}
|
||||
// FormatFunc is fulfilled by FromPlain,
|
||||
// FromPlainNoParagraph, and FromMarkdown.
|
||||
type FormatFunc func(
|
||||
ctx context.Context,
|
||||
parseMention gtsmodel.ParseMentionFunc,
|
||||
authorID string,
|
||||
statusID string,
|
||||
text string,
|
||||
) *FormatResult
|
||||
|
||||
type FormatFunc func(ctx context.Context, pmf gtsmodel.ParseMentionFunc, authorID string, statusID string, text string) *FormatResult
|
||||
|
||||
type formatter struct {
|
||||
// Formatter wraps logic and functions for parsing
|
||||
// statuses and other text input into nice html.
|
||||
type Formatter struct {
|
||||
db db.DB
|
||||
}
|
||||
|
||||
// NewFormatter returns a new Formatter interface for parsing statuses and other text input into nice html.
|
||||
func NewFormatter(db db.DB) Formatter {
|
||||
return &formatter{
|
||||
// NewFormatter returns a new Formatter.
|
||||
func NewFormatter(db db.DB) *Formatter {
|
||||
return &Formatter{
|
||||
db: db,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user