From 2e7c6b009852177e2be5c33aef5ff52e8c5505cb Mon Sep 17 00:00:00 2001 From: "diamondburned (Forefront)" Date: Tue, 9 Jun 2020 20:51:54 -0700 Subject: [PATCH] Added blocks into richtext and AttrDim into inline attributes --- text/text.go | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/text/text.go b/text/text.go index 483d64b..a82620f 100644 --- a/text/text.go +++ b/text/text.go @@ -23,24 +23,28 @@ type Segment interface { // that the segment should be replaced with a hyperlink, similarly to the anchor // tag with href being the URL and the inner text being the text string. type Linker interface { + Segment Link() (text, url string) } // Imager implies the segment should be replaced with a (possibly inlined) // image. type Imager interface { + Segment Image() (url string) } // Colorer is a text color format that a segment could implement. This is to be // applied directly onto the text. type Colorer interface { + Segment Color() uint32 } // Attributor is a rich text markup format that a segment could implement. This // is to be applied directly onto the text. type Attributor interface { + Segment Attribute() Attribute } @@ -48,11 +52,39 @@ type Attributor interface { type Attribute uint16 const ( + // AttrBold represents bold text. AttrBold Attribute = 1 << iota + // AttrItalics represents italicized text. AttrItalics + // AttrUnderline represents underlined text. AttrUnderline + // AttrStrikethrough represents strikethrough text. AttrStrikethrough + // AttrSpoiler represents spoiler text, which usually looks blacked out + // until hovered or clicked on. AttrSpoiler + // AttrMonospace represents monospaced text, typically for inline code. AttrMonospace - AttrQuoted + // AttrDimmed represents dimmed text, typically slightly less visible than + // other text. + AttrDimmed ) + +// Codeblocker is a codeblock that supports optional syntax highlighting using +// the language given. Note that as this is a block, it will appear separately +// from the rest of the paragraph. +// +// This interface is equivalent to Markdown's codeblock syntax. +type Codeblocker interface { + Segment + CodeblockLanguage() string +} + +// Quoteblocker represents a quoteblock that behaves similarly to the blockquote +// HTML tag. The quoteblock may be represented typically by an actaul quoteblock +// or with green arrows prepended to each line. +type Quoteblocker interface { + Segment + // Quote does nothing; it's only here to distinguish the interface. + Quote() +}