mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 08:57:14 -04:00
Define default styles in Go, not JSON
This commit is contained in:
committed by
Christian Muehlhaeuser
parent
40817a7a74
commit
6b9278b445
+93
-90
@@ -4,136 +4,139 @@ import (
|
|||||||
"github.com/lucasb-eyer/go-colorful"
|
"github.com/lucasb-eyer/go-colorful"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Chroma holds all the chroma settings.
|
||||||
|
type Chroma struct {
|
||||||
|
Text StylePrimitive `json:"text,omitempty"`
|
||||||
|
Error StylePrimitive `json:"error,omitempty"`
|
||||||
|
Comment StylePrimitive `json:"comment,omitempty"`
|
||||||
|
CommentPreproc StylePrimitive `json:"comment_preproc,omitempty"`
|
||||||
|
Keyword StylePrimitive `json:"keyword,omitempty"`
|
||||||
|
KeywordReserved StylePrimitive `json:"keyword_reserved,omitempty"`
|
||||||
|
KeywordNamespace StylePrimitive `json:"keyword_namespace,omitempty"`
|
||||||
|
KeywordType StylePrimitive `json:"keyword_type,omitempty"`
|
||||||
|
Operator StylePrimitive `json:"operator,omitempty"`
|
||||||
|
Punctuation StylePrimitive `json:"punctuation,omitempty"`
|
||||||
|
Name StylePrimitive `json:"name,omitempty"`
|
||||||
|
NameBuiltin StylePrimitive `json:"name_builtin,omitempty"`
|
||||||
|
NameTag StylePrimitive `json:"name_tag,omitempty"`
|
||||||
|
NameAttribute StylePrimitive `json:"name_attribute,omitempty"`
|
||||||
|
NameClass StylePrimitive `json:"name_class,omitempty"`
|
||||||
|
NameConstant StylePrimitive `json:"name_constant,omitempty"`
|
||||||
|
NameDecorator StylePrimitive `json:"name_decorator,omitempty"`
|
||||||
|
NameException StylePrimitive `json:"name_exception,omitempty"`
|
||||||
|
NameFunction StylePrimitive `json:"name_function,omitempty"`
|
||||||
|
NameOther StylePrimitive `json:"name_other,omitempty"`
|
||||||
|
Literal StylePrimitive `json:"literal,omitempty"`
|
||||||
|
LiteralNumber StylePrimitive `json:"literal_number,omitempty"`
|
||||||
|
LiteralDate StylePrimitive `json:"literal_date,omitempty"`
|
||||||
|
LiteralString StylePrimitive `json:"literal_string,omitempty"`
|
||||||
|
LiteralStringEscape StylePrimitive `json:"literal_string_escape,omitempty"`
|
||||||
|
GenericDeleted StylePrimitive `json:"generic_deleted,omitempty"`
|
||||||
|
GenericEmph StylePrimitive `json:"generic_emph,omitempty"`
|
||||||
|
GenericInserted StylePrimitive `json:"generic_inserted,omitempty"`
|
||||||
|
GenericStrong StylePrimitive `json:"generic_strong,omitempty"`
|
||||||
|
GenericSubheading StylePrimitive `json:"generic_subheading,omitempty"`
|
||||||
|
Background StylePrimitive `json:"background,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// StylePrimitive holds all the basic style settings.
|
// StylePrimitive holds all the basic style settings.
|
||||||
type StylePrimitive struct {
|
type StylePrimitive struct {
|
||||||
BlockPrefix string `json:"block_prefix"`
|
BlockPrefix string `json:"block_prefix,omitempty"`
|
||||||
BlockSuffix string `json:"block_suffix"`
|
BlockSuffix string `json:"block_suffix,omitempty"`
|
||||||
Prefix string `json:"prefix"`
|
Prefix string `json:"prefix,omitempty"`
|
||||||
Suffix string `json:"suffix"`
|
Suffix string `json:"suffix,omitempty"`
|
||||||
Color *string `json:"color"`
|
Color *string `json:"color,omitempty"`
|
||||||
BackgroundColor *string `json:"background_color"`
|
BackgroundColor *string `json:"background_color,omitempty"`
|
||||||
Underline *bool `json:"underline"`
|
Underline *bool `json:"underline,omitempty"`
|
||||||
Bold *bool `json:"bold"`
|
Bold *bool `json:"bold,omitempty"`
|
||||||
Italic *bool `json:"italic"`
|
Italic *bool `json:"italic,omitempty"`
|
||||||
CrossedOut *bool `json:"crossed_out"`
|
CrossedOut *bool `json:"crossed_out,omitempty"`
|
||||||
Faint *bool `json:"faint"`
|
Faint *bool `json:"faint,omitempty"`
|
||||||
Conceal *bool `json:"conceal"`
|
Conceal *bool `json:"conceal,omitempty"`
|
||||||
Overlined *bool `json:"overlined"`
|
Overlined *bool `json:"overlined,omitempty"`
|
||||||
Inverse *bool `json:"inverse"`
|
Inverse *bool `json:"inverse,omitempty"`
|
||||||
Blink *bool `json:"blink"`
|
Blink *bool `json:"blink,omitempty"`
|
||||||
Format string `json:"format"`
|
Format string `json:"format,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleTask holds the style settings for a task item.
|
// StyleTask holds the style settings for a task item.
|
||||||
type StyleTask struct {
|
type StyleTask struct {
|
||||||
StylePrimitive
|
StylePrimitive
|
||||||
Ticked string `json:"ticked"`
|
Ticked string `json:"ticked,omitempty"`
|
||||||
Unticked string `json:"unticked"`
|
Unticked string `json:"unticked,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleBlock holds the basic style settings for block elements.
|
// StyleBlock holds the basic style settings for block elements.
|
||||||
type StyleBlock struct {
|
type StyleBlock struct {
|
||||||
StylePrimitive
|
StylePrimitive
|
||||||
Indent *uint `json:"indent"`
|
Indent *uint `json:"indent,omitempty"`
|
||||||
IndentToken *string `json:"indent_token"`
|
IndentToken *string `json:"indent_token,omitempty"`
|
||||||
Margin *uint `json:"margin"`
|
Margin *uint `json:"margin,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleCodeBlock holds the style settings for a code block.
|
// StyleCodeBlock holds the style settings for a code block.
|
||||||
type StyleCodeBlock struct {
|
type StyleCodeBlock struct {
|
||||||
StyleBlock
|
StyleBlock
|
||||||
Theme string `json:"theme"`
|
Theme string `json:"theme,omitempty"`
|
||||||
Chroma *struct {
|
Chroma *Chroma `json:"chroma,omitempty"`
|
||||||
Text StylePrimitive `json:"text"`
|
|
||||||
Error StylePrimitive `json:"error"`
|
|
||||||
Comment StylePrimitive `json:"comment"`
|
|
||||||
CommentPreproc StylePrimitive `json:"comment_preproc"`
|
|
||||||
Keyword StylePrimitive `json:"keyword"`
|
|
||||||
KeywordReserved StylePrimitive `json:"keyword_reserved"`
|
|
||||||
KeywordNamespace StylePrimitive `json:"keyword_namespace"`
|
|
||||||
KeywordType StylePrimitive `json:"keyword_type"`
|
|
||||||
Operator StylePrimitive `json:"operator"`
|
|
||||||
Punctuation StylePrimitive `json:"punctuation"`
|
|
||||||
Name StylePrimitive `json:"name"`
|
|
||||||
NameBuiltin StylePrimitive `json:"name_builtin"`
|
|
||||||
NameTag StylePrimitive `json:"name_tag"`
|
|
||||||
NameAttribute StylePrimitive `json:"name_attribute"`
|
|
||||||
NameClass StylePrimitive `json:"name_class"`
|
|
||||||
NameConstant StylePrimitive `json:"name_constant"`
|
|
||||||
NameDecorator StylePrimitive `json:"name_decorator"`
|
|
||||||
NameException StylePrimitive `json:"name_exception"`
|
|
||||||
NameFunction StylePrimitive `json:"name_function"`
|
|
||||||
NameOther StylePrimitive `json:"name_other"`
|
|
||||||
Literal StylePrimitive `json:"literal"`
|
|
||||||
LiteralNumber StylePrimitive `json:"literal_number"`
|
|
||||||
LiteralDate StylePrimitive `json:"literal_date"`
|
|
||||||
LiteralString StylePrimitive `json:"literal_string"`
|
|
||||||
LiteralStringEscape StylePrimitive `json:"literal_string_escape"`
|
|
||||||
GenericDeleted StylePrimitive `json:"generic_deleted"`
|
|
||||||
GenericEmph StylePrimitive `json:"generic_emph"`
|
|
||||||
GenericInserted StylePrimitive `json:"generic_inserted"`
|
|
||||||
GenericStrong StylePrimitive `json:"generic_strong"`
|
|
||||||
GenericSubheading StylePrimitive `json:"generic_subheading"`
|
|
||||||
Background StylePrimitive `json:"background"`
|
|
||||||
} `json:"chroma"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleList holds the style settings for a list.
|
// StyleList holds the style settings for a list.
|
||||||
type StyleList struct {
|
type StyleList struct {
|
||||||
StyleBlock
|
StyleBlock
|
||||||
LevelIndent uint `json:"level_indent"`
|
LevelIndent uint `json:"level_indent,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleTable holds the style settings for a table.
|
// StyleTable holds the style settings for a table.
|
||||||
type StyleTable struct {
|
type StyleTable struct {
|
||||||
StyleBlock
|
StyleBlock
|
||||||
CenterSeparator *string `json:"center_separator"`
|
CenterSeparator *string `json:"center_separator,omitempty"`
|
||||||
ColumnSeparator *string `json:"column_separator"`
|
ColumnSeparator *string `json:"column_separator,omitempty"`
|
||||||
RowSeparator *string `json:"row_separator"`
|
RowSeparator *string `json:"row_separator,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// StyleConfig is used to configure the styling behavior of an ANSIRenderer.
|
// StyleConfig is used to configure the styling behavior of an ANSIRenderer.
|
||||||
type StyleConfig struct {
|
type StyleConfig struct {
|
||||||
Document StyleBlock `json:"document"`
|
Document StyleBlock `json:"document,omitempty"`
|
||||||
BlockQuote StyleBlock `json:"block_quote"`
|
BlockQuote StyleBlock `json:"block_quote,omitempty"`
|
||||||
Paragraph StyleBlock `json:"paragraph"`
|
Paragraph StyleBlock `json:"paragraph,omitempty"`
|
||||||
List StyleList `json:"list"`
|
List StyleList `json:"list,omitempty"`
|
||||||
|
|
||||||
Heading StyleBlock `json:"heading"`
|
Heading StyleBlock `json:"heading,omitempty"`
|
||||||
H1 StyleBlock `json:"h1"`
|
H1 StyleBlock `json:"h1,omitempty"`
|
||||||
H2 StyleBlock `json:"h2"`
|
H2 StyleBlock `json:"h2,omitempty"`
|
||||||
H3 StyleBlock `json:"h3"`
|
H3 StyleBlock `json:"h3,omitempty"`
|
||||||
H4 StyleBlock `json:"h4"`
|
H4 StyleBlock `json:"h4,omitempty"`
|
||||||
H5 StyleBlock `json:"h5"`
|
H5 StyleBlock `json:"h5,omitempty"`
|
||||||
H6 StyleBlock `json:"h6"`
|
H6 StyleBlock `json:"h6,omitempty"`
|
||||||
|
|
||||||
Text StylePrimitive `json:"text"`
|
Text StylePrimitive `json:"text,omitempty"`
|
||||||
Strikethrough StylePrimitive `json:"strikethrough"`
|
Strikethrough StylePrimitive `json:"strikethrough,omitempty"`
|
||||||
Emph StylePrimitive `json:"emph"`
|
Emph StylePrimitive `json:"emph,omitempty"`
|
||||||
Strong StylePrimitive `json:"strong"`
|
Strong StylePrimitive `json:"strong,omitempty"`
|
||||||
HorizontalRule StylePrimitive `json:"hr"`
|
HorizontalRule StylePrimitive `json:"hr,omitempty"`
|
||||||
|
|
||||||
Item StylePrimitive `json:"item"`
|
Item StylePrimitive `json:"item,omitempty"`
|
||||||
Enumeration StylePrimitive `json:"enumeration"`
|
Enumeration StylePrimitive `json:"enumeration,omitempty"`
|
||||||
Task StyleTask `json:"task"`
|
Task StyleTask `json:"task,omitempty"`
|
||||||
|
|
||||||
Link StylePrimitive `json:"link"`
|
Link StylePrimitive `json:"link,omitempty"`
|
||||||
LinkText StylePrimitive `json:"link_text"`
|
LinkText StylePrimitive `json:"link_text,omitempty"`
|
||||||
|
|
||||||
Image StylePrimitive `json:"image"`
|
Image StylePrimitive `json:"image,omitempty"`
|
||||||
ImageText StylePrimitive `json:"image_text"`
|
ImageText StylePrimitive `json:"image_text,omitempty"`
|
||||||
|
|
||||||
Code StyleBlock `json:"code"`
|
Code StyleBlock `json:"code,omitempty"`
|
||||||
CodeBlock StyleCodeBlock `json:"code_block"`
|
CodeBlock StyleCodeBlock `json:"code_block,omitempty"`
|
||||||
|
|
||||||
Table StyleTable `json:"table"`
|
Table StyleTable `json:"table,omitempty"`
|
||||||
|
|
||||||
DefinitionList StyleBlock `json:"definition_list"`
|
DefinitionList StyleBlock `json:"definition_list,omitempty"`
|
||||||
DefinitionTerm StylePrimitive `json:"definition_term"`
|
DefinitionTerm StylePrimitive `json:"definition_term,omitempty"`
|
||||||
DefinitionDescription StylePrimitive `json:"definition_description"`
|
DefinitionDescription StylePrimitive `json:"definition_description,omitempty"`
|
||||||
|
|
||||||
HTMLBlock StyleBlock `json:"html_block"`
|
HTMLBlock StyleBlock `json:"html_block,omitempty"`
|
||||||
HTMLSpan StyleBlock `json:"html_span"`
|
HTMLSpan StyleBlock `json:"html_span,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func cascadeStyles(toBlock bool, s ...StyleBlock) StyleBlock {
|
func cascadeStyles(toBlock bool, s ...StyleBlock) StyleBlock {
|
||||||
|
|||||||
@@ -0,0 +1,636 @@
|
|||||||
|
package glamour
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/charmbracelet/glamour/ansi"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// DarkStyleConfig is the default dark style.
|
||||||
|
DarkStyleConfig = ansi.StyleConfig{
|
||||||
|
Document: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "\n",
|
||||||
|
BlockSuffix: "\n",
|
||||||
|
Color: stringPtr("252"),
|
||||||
|
},
|
||||||
|
Indent: uintPtr(2),
|
||||||
|
},
|
||||||
|
BlockQuote: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
Indent: uintPtr(1),
|
||||||
|
IndentToken: stringPtr("│ "),
|
||||||
|
},
|
||||||
|
List: ansi.StyleList{
|
||||||
|
LevelIndent: 2,
|
||||||
|
},
|
||||||
|
Heading: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockSuffix: "\n",
|
||||||
|
Color: stringPtr("39"),
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H1: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: " ",
|
||||||
|
Suffix: " ",
|
||||||
|
Color: stringPtr("228"),
|
||||||
|
BackgroundColor: stringPtr("63"),
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H2: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "## ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H3: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H4: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "#### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H5: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "##### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H6: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "###### ",
|
||||||
|
Color: stringPtr("35"),
|
||||||
|
Bold: boolPtr(false),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Strikethrough: ansi.StylePrimitive{
|
||||||
|
CrossedOut: boolPtr(true),
|
||||||
|
},
|
||||||
|
Emph: ansi.StylePrimitive{
|
||||||
|
Italic: boolPtr(true),
|
||||||
|
},
|
||||||
|
Strong: ansi.StylePrimitive{
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
HorizontalRule: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("240"),
|
||||||
|
Format: "\n--------\n",
|
||||||
|
},
|
||||||
|
Item: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "• ",
|
||||||
|
},
|
||||||
|
Enumeration: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: ". ",
|
||||||
|
},
|
||||||
|
Task: ansi.StyleTask{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
Ticked: "[✓] ",
|
||||||
|
Unticked: "[ ] ",
|
||||||
|
},
|
||||||
|
Link: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("30"),
|
||||||
|
Underline: boolPtr(true),
|
||||||
|
},
|
||||||
|
LinkText: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("35"),
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
Image: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("212"),
|
||||||
|
Underline: boolPtr(true),
|
||||||
|
},
|
||||||
|
ImageText: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("243"),
|
||||||
|
Format: "Image: {{.text}} →",
|
||||||
|
},
|
||||||
|
Code: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: " ",
|
||||||
|
Suffix: " ",
|
||||||
|
Color: stringPtr("203"),
|
||||||
|
BackgroundColor: stringPtr("236"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
CodeBlock: ansi.StyleCodeBlock{
|
||||||
|
StyleBlock: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("244"),
|
||||||
|
},
|
||||||
|
Margin: uintPtr(2),
|
||||||
|
},
|
||||||
|
Chroma: &ansi.Chroma{
|
||||||
|
Text: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#C4C4C4"),
|
||||||
|
},
|
||||||
|
Error: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#F1F1F1"),
|
||||||
|
BackgroundColor: stringPtr("#F05B5B"),
|
||||||
|
},
|
||||||
|
Comment: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#676767"),
|
||||||
|
},
|
||||||
|
CommentPreproc: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FF875F"),
|
||||||
|
},
|
||||||
|
Keyword: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#00AAFF"),
|
||||||
|
},
|
||||||
|
KeywordReserved: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FF5FD2"),
|
||||||
|
},
|
||||||
|
KeywordNamespace: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FF5F87"),
|
||||||
|
},
|
||||||
|
KeywordType: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#6E6ED8"),
|
||||||
|
},
|
||||||
|
Operator: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#EF8080"),
|
||||||
|
},
|
||||||
|
Punctuation: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#E8E8A8"),
|
||||||
|
},
|
||||||
|
Name: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#C4C4C4"),
|
||||||
|
},
|
||||||
|
NameBuiltin: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FF8EC7"),
|
||||||
|
},
|
||||||
|
NameTag: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#B083EA"),
|
||||||
|
},
|
||||||
|
NameAttribute: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#7A7AE6"),
|
||||||
|
},
|
||||||
|
NameClass: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#F1F1F1"),
|
||||||
|
Underline: boolPtr(true),
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
NameDecorator: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FFFF87"),
|
||||||
|
},
|
||||||
|
NameFunction: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#00D787"),
|
||||||
|
},
|
||||||
|
LiteralNumber: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#6EEFC0"),
|
||||||
|
},
|
||||||
|
LiteralString: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#C69669"),
|
||||||
|
},
|
||||||
|
LiteralStringEscape: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#AFFFD7"),
|
||||||
|
},
|
||||||
|
GenericDeleted: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FD5B5B"),
|
||||||
|
},
|
||||||
|
GenericEmph: ansi.StylePrimitive{
|
||||||
|
Italic: boolPtr(true),
|
||||||
|
},
|
||||||
|
GenericInserted: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#00D787"),
|
||||||
|
},
|
||||||
|
GenericStrong: ansi.StylePrimitive{
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
GenericSubheading: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#777777"),
|
||||||
|
},
|
||||||
|
Background: ansi.StylePrimitive{
|
||||||
|
BackgroundColor: stringPtr("#373737"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Table: ansi.StyleTable{
|
||||||
|
StyleBlock: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
},
|
||||||
|
CenterSeparator: stringPtr("┼"),
|
||||||
|
ColumnSeparator: stringPtr("│"),
|
||||||
|
RowSeparator: stringPtr("─"),
|
||||||
|
},
|
||||||
|
DefinitionDescription: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "\n🠶 ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// LightStyleConfig is the default light style.
|
||||||
|
LightStyleConfig = ansi.StyleConfig{
|
||||||
|
Document: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "\n",
|
||||||
|
BlockSuffix: "\n",
|
||||||
|
Color: stringPtr("234"),
|
||||||
|
},
|
||||||
|
Indent: uintPtr(2),
|
||||||
|
},
|
||||||
|
BlockQuote: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
Indent: uintPtr(1),
|
||||||
|
IndentToken: stringPtr("│ "),
|
||||||
|
},
|
||||||
|
List: ansi.StyleList{
|
||||||
|
LevelIndent: 2,
|
||||||
|
},
|
||||||
|
Heading: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockSuffix: "\n",
|
||||||
|
Color: stringPtr("27"),
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H1: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: " ",
|
||||||
|
Suffix: " ",
|
||||||
|
Color: stringPtr("228"),
|
||||||
|
BackgroundColor: stringPtr("63"),
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H2: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "## ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H3: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H4: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "#### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H5: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "##### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H6: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "###### ",
|
||||||
|
Bold: boolPtr(false),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Strikethrough: ansi.StylePrimitive{
|
||||||
|
CrossedOut: boolPtr(true),
|
||||||
|
},
|
||||||
|
Emph: ansi.StylePrimitive{
|
||||||
|
Italic: boolPtr(true),
|
||||||
|
},
|
||||||
|
Strong: ansi.StylePrimitive{
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
HorizontalRule: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("249"),
|
||||||
|
Format: "\n--------\n",
|
||||||
|
},
|
||||||
|
Item: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "• ",
|
||||||
|
},
|
||||||
|
Enumeration: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: ". ",
|
||||||
|
},
|
||||||
|
Task: ansi.StyleTask{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
Ticked: "[✓] ",
|
||||||
|
Unticked: "[ ] ",
|
||||||
|
},
|
||||||
|
Link: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("36"),
|
||||||
|
Underline: boolPtr(true),
|
||||||
|
},
|
||||||
|
LinkText: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("29"),
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
Image: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("205"),
|
||||||
|
Underline: boolPtr(true),
|
||||||
|
},
|
||||||
|
ImageText: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("243"),
|
||||||
|
Format: "Image: {{.text}} →",
|
||||||
|
},
|
||||||
|
Code: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: " ",
|
||||||
|
Suffix: " ",
|
||||||
|
Color: stringPtr("203"),
|
||||||
|
BackgroundColor: stringPtr("254"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
CodeBlock: ansi.StyleCodeBlock{
|
||||||
|
StyleBlock: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("242"),
|
||||||
|
},
|
||||||
|
Margin: uintPtr(2),
|
||||||
|
},
|
||||||
|
Chroma: &ansi.Chroma{
|
||||||
|
Text: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#2A2A2A"),
|
||||||
|
},
|
||||||
|
Error: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#F1F1F1"),
|
||||||
|
BackgroundColor: stringPtr("#FF5555"),
|
||||||
|
},
|
||||||
|
Comment: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#8D8D8D"),
|
||||||
|
},
|
||||||
|
CommentPreproc: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FF875F"),
|
||||||
|
},
|
||||||
|
Keyword: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#279EFC"),
|
||||||
|
},
|
||||||
|
KeywordReserved: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FF5FD2"),
|
||||||
|
},
|
||||||
|
KeywordNamespace: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FB406F"),
|
||||||
|
},
|
||||||
|
KeywordType: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#7049C2"),
|
||||||
|
},
|
||||||
|
Operator: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FF2626"),
|
||||||
|
},
|
||||||
|
Punctuation: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FA7878"),
|
||||||
|
},
|
||||||
|
NameBuiltin: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#0A1BB1"),
|
||||||
|
},
|
||||||
|
NameTag: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#581290"),
|
||||||
|
},
|
||||||
|
NameAttribute: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#8362CB"),
|
||||||
|
},
|
||||||
|
NameClass: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#212121"),
|
||||||
|
Underline: boolPtr(true),
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
NameConstant: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#581290"),
|
||||||
|
},
|
||||||
|
NameDecorator: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#A3A322"),
|
||||||
|
},
|
||||||
|
NameFunction: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#019F57"),
|
||||||
|
},
|
||||||
|
LiteralNumber: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#22CCAE"),
|
||||||
|
},
|
||||||
|
LiteralString: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#7E5B38"),
|
||||||
|
},
|
||||||
|
LiteralStringEscape: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#00AEAE"),
|
||||||
|
},
|
||||||
|
GenericDeleted: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#FD5B5B"),
|
||||||
|
},
|
||||||
|
GenericEmph: ansi.StylePrimitive{
|
||||||
|
Italic: boolPtr(true),
|
||||||
|
},
|
||||||
|
GenericInserted: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#00D787"),
|
||||||
|
},
|
||||||
|
GenericStrong: ansi.StylePrimitive{
|
||||||
|
Bold: boolPtr(true),
|
||||||
|
},
|
||||||
|
GenericSubheading: ansi.StylePrimitive{
|
||||||
|
Color: stringPtr("#777777"),
|
||||||
|
},
|
||||||
|
Background: ansi.StylePrimitive{
|
||||||
|
BackgroundColor: stringPtr("#373737"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Table: ansi.StyleTable{
|
||||||
|
StyleBlock: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
},
|
||||||
|
CenterSeparator: stringPtr("┼"),
|
||||||
|
ColumnSeparator: stringPtr("│"),
|
||||||
|
RowSeparator: stringPtr("─"),
|
||||||
|
},
|
||||||
|
DefinitionDescription: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "\n🠶 ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// NoTTYStyleConfig is the default notty style.
|
||||||
|
NoTTYStyleConfig = ansi.StyleConfig{
|
||||||
|
Document: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "\n",
|
||||||
|
BlockSuffix: "\n",
|
||||||
|
},
|
||||||
|
Indent: uintPtr(2),
|
||||||
|
},
|
||||||
|
BlockQuote: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
Indent: uintPtr(1),
|
||||||
|
IndentToken: stringPtr("│ "),
|
||||||
|
},
|
||||||
|
Paragraph: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
},
|
||||||
|
List: ansi.StyleList{
|
||||||
|
StyleBlock: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
},
|
||||||
|
LevelIndent: 4,
|
||||||
|
},
|
||||||
|
Heading: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockSuffix: "\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H1: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "# ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H2: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "## ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H3: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H4: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "#### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H5: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "##### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H6: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "###### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Strikethrough: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "~~",
|
||||||
|
BlockSuffix: "~~",
|
||||||
|
},
|
||||||
|
Emph: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "*",
|
||||||
|
BlockSuffix: "*",
|
||||||
|
},
|
||||||
|
Strong: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "**",
|
||||||
|
BlockSuffix: "**",
|
||||||
|
},
|
||||||
|
HorizontalRule: ansi.StylePrimitive{
|
||||||
|
Format: "\n--------\n",
|
||||||
|
},
|
||||||
|
Item: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "• ",
|
||||||
|
},
|
||||||
|
Enumeration: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: ". ",
|
||||||
|
},
|
||||||
|
Task: ansi.StyleTask{
|
||||||
|
Ticked: "[✓] ",
|
||||||
|
Unticked: "[ ] ",
|
||||||
|
},
|
||||||
|
ImageText: ansi.StylePrimitive{
|
||||||
|
Format: "Image: {{.text}} →",
|
||||||
|
},
|
||||||
|
Code: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "`",
|
||||||
|
BlockSuffix: "`",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
CodeBlock: ansi.StyleCodeBlock{
|
||||||
|
StyleBlock: ansi.StyleBlock{
|
||||||
|
Margin: uintPtr(2),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Table: ansi.StyleTable{
|
||||||
|
CenterSeparator: stringPtr("┼"),
|
||||||
|
ColumnSeparator: stringPtr("│"),
|
||||||
|
RowSeparator: stringPtr("─"),
|
||||||
|
},
|
||||||
|
DefinitionDescription: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "\n🠶 ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SimpleStyleConfig is the default simple style.
|
||||||
|
SimpleStyleConfig = ansi.StyleConfig{
|
||||||
|
BlockQuote: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
Indent: uintPtr(1),
|
||||||
|
IndentToken: stringPtr("> "),
|
||||||
|
},
|
||||||
|
List: ansi.StyleList{
|
||||||
|
LevelIndent: 4,
|
||||||
|
},
|
||||||
|
Heading: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockSuffix: "\n",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H1: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockSuffix: "\n\n",
|
||||||
|
Prefix: "# ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H2: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "## ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H3: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H4: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "#### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H5: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "##### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
H6: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
Prefix: "###### ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Text: ansi.StylePrimitive{},
|
||||||
|
Strikethrough: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "~~",
|
||||||
|
BlockSuffix: "~~",
|
||||||
|
},
|
||||||
|
Emph: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "*",
|
||||||
|
BlockSuffix: "*",
|
||||||
|
},
|
||||||
|
Strong: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "**",
|
||||||
|
BlockSuffix: "**",
|
||||||
|
},
|
||||||
|
HorizontalRule: ansi.StylePrimitive{
|
||||||
|
Format: "\n--------\n",
|
||||||
|
},
|
||||||
|
Item: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "- ",
|
||||||
|
},
|
||||||
|
Enumeration: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: ". ",
|
||||||
|
},
|
||||||
|
Task: ansi.StyleTask{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{},
|
||||||
|
},
|
||||||
|
ImageText: ansi.StylePrimitive{
|
||||||
|
Format: "Image: {{.text}} => ",
|
||||||
|
},
|
||||||
|
Code: ansi.StyleBlock{
|
||||||
|
StylePrimitive: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "`",
|
||||||
|
BlockSuffix: "`",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DefinitionDescription: ansi.StylePrimitive{
|
||||||
|
BlockPrefix: "\n: ",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// DefaultStyles are the default styles.
|
||||||
|
DefaultStyles = map[string]*ansi.StyleConfig{
|
||||||
|
"dark": &DarkStyleConfig,
|
||||||
|
"light": &LightStyleConfig,
|
||||||
|
"notty": &NoTTYStyleConfig,
|
||||||
|
"simple": &SimpleStyleConfig,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func boolPtr(b bool) *bool { return &b }
|
||||||
|
func stringPtr(s string) *string { return &s }
|
||||||
|
func uintPtr(u uint) *uint { return &u }
|
||||||
Reference in New Issue
Block a user