Skip to content

Commit

Permalink
fix: tokyo night
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Alexandro Becker <[email protected]>
  • Loading branch information
caarlos0 committed Jul 30, 2024
1 parent bd7263b commit fbf8be6
Show file tree
Hide file tree
Showing 4 changed files with 228 additions and 22 deletions.
15 changes: 8 additions & 7 deletions glamour.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ import (

// Default styles.
const (
AsciiStyle = "ascii"
AutoStyle = "auto"
DarkStyle = "dark"
DraculaStyle = "dracula"
LightStyle = "light"
NoTTYStyle = "notty"
PinkStyle = "pink"
AsciiStyle = "ascii"
AutoStyle = "auto"
DarkStyle = "dark"
DraculaStyle = "dracula"
TokyoNightStyle = "tokyo-night"
LightStyle = "light"
NoTTYStyle = "notty"
PinkStyle = "pink"
)

const (
Expand Down
219 changes: 213 additions & 6 deletions styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,17 +642,224 @@ var (
HTMLSpan: ansi.StyleBlock{},
}

// TokyoNightStyle is the tokyo night style.
TokyoNightStyleConfig = ansi.StyleConfig{
Document: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
BlockPrefix: "\n",
BlockSuffix: "\n",
Color: stringPtr("#a9b1d6"),
},
Margin: uintPtr(defaultMargin),
},
BlockQuote: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{},
Indent: uintPtr(1),
IndentToken: stringPtr("│ "),
},
List: ansi.StyleList{
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#a9b1d6"),
},
},
LevelIndent: defaultListIndent,
},
Heading: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
BlockSuffix: "\n",
Color: stringPtr("#bb9af7"),
Bold: boolPtr(true),
},
},
H1: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Prefix: "# ",
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: "###### ",
},
},
Strikethrough: ansi.StylePrimitive{
CrossedOut: boolPtr(true),
},
Emph: ansi.StylePrimitive{
Italic: boolPtr(true),
},
Strong: ansi.StylePrimitive{
Bold: boolPtr(true),
},
HorizontalRule: ansi.StylePrimitive{
Color: stringPtr("#565f89"),
Format: "\n--------\n",
},
Item: ansi.StylePrimitive{
BlockPrefix: "• ",
},
Enumeration: ansi.StylePrimitive{
BlockPrefix: ". ",
Color: stringPtr("#7aa2f7"),
},
Task: ansi.StyleTask{
StylePrimitive: ansi.StylePrimitive{},
Ticked: "[✓] ",
Unticked: "[ ] ",
},
Link: ansi.StylePrimitive{
Color: stringPtr("#7aa2f7"),
Underline: boolPtr(true),
},
LinkText: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
},
Image: ansi.StylePrimitive{
Color: stringPtr("#7aa2f7"),
Underline: boolPtr(true),
},
ImageText: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
Format: "Image: {{.text}} →",
},
Code: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#9ece6a"),
},
},
CodeBlock: ansi.StyleCodeBlock{
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#ff9e64"),
},
Margin: uintPtr(defaultMargin),
},
Chroma: &ansi.Chroma{
Text: ansi.StylePrimitive{
Color: stringPtr("#a9b1d6"),
},
Error: ansi.StylePrimitive{
Color: stringPtr("#a9b1d6"),
BackgroundColor: stringPtr("#f7768e"),
},
Comment: ansi.StylePrimitive{
Color: stringPtr("#565f89"),
},
CommentPreproc: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
},
Keyword: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
},
KeywordReserved: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
},
KeywordNamespace: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
},
KeywordType: ansi.StylePrimitive{
Color: stringPtr("#7aa2f7"),
},
Operator: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
},
Punctuation: ansi.StylePrimitive{
Color: stringPtr("#a9b1d6"),
},
Name: ansi.StylePrimitive{
Color: stringPtr("#7aa2f7"),
},
NameConstant: ansi.StylePrimitive{
Color: stringPtr("#bb9af7"),
},
NameBuiltin: ansi.StylePrimitive{
Color: stringPtr("#7aa2f7"),
},
NameTag: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
},
NameAttribute: ansi.StylePrimitive{
Color: stringPtr("#9ece6a"),
},
NameClass: ansi.StylePrimitive{
Color: stringPtr("#7aa2f7"),
},
NameDecorator: ansi.StylePrimitive{
Color: stringPtr("#9ece6a"),
},
NameFunction: ansi.StylePrimitive{
Color: stringPtr("#9ece6a"),
},
LiteralNumber: ansi.StylePrimitive{},
LiteralString: ansi.StylePrimitive{
Color: stringPtr("#e0af68"),
},
LiteralStringEscape: ansi.StylePrimitive{
Color: stringPtr("#2ac3de"),
},
GenericDeleted: ansi.StylePrimitive{
Color: stringPtr("#f7768e"),
},
GenericEmph: ansi.StylePrimitive{
Italic: boolPtr(true),
},
GenericInserted: ansi.StylePrimitive{
Color: stringPtr("#9ece6a"),
},
GenericStrong: ansi.StylePrimitive{
Bold: boolPtr(true),
},
GenericSubheading: ansi.StylePrimitive{
Color: stringPtr("#bb9af7"),
},
Background: ansi.StylePrimitive{
BackgroundColor: stringPtr("#1a1b26"),
},
},
},
Table: ansi.StyleTable{
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{},
},
},
DefinitionDescription: ansi.StylePrimitive{
BlockPrefix: "\n🠶 ",
},
}

// NoTTYStyleConfig is the default notty style.
NoTTYStyleConfig = ASCIIStyleConfig

// DefaultStyles are the default styles.
DefaultStyles = map[string]*ansi.StyleConfig{
AsciiStyle: &ASCIIStyleConfig,
DarkStyle: &DarkStyleConfig,
DraculaStyle: &DraculaStyleConfig,
LightStyle: &LightStyleConfig,
NoTTYStyle: &NoTTYStyleConfig,
PinkStyle: &PinkStyleConfig,
AsciiStyle: &ASCIIStyleConfig,
DarkStyle: &DarkStyleConfig,
DraculaStyle: &DraculaStyleConfig,
TokyoNightStyle: &TokyoNightStyleConfig,
LightStyle: &LightStyleConfig,
NoTTYStyle: &NoTTYStyleConfig,
PinkStyle: &PinkStyleConfig,
}
)

Expand Down
12 changes: 4 additions & 8 deletions styles/notty.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
},
"block_quote": {
"indent": 1,
"indent_token": " "
"indent_token": "| "
},
"paragraph": {},
"list": {
Expand Down Expand Up @@ -56,7 +56,7 @@
"block_prefix": ". "
},
"task": {
"ticked": "[] ",
"ticked": "[x] ",
"unticked": "[ ] "
},
"link": {},
Expand All @@ -72,15 +72,11 @@
"code_block": {
"margin": 2
},
"table": {
"center_separator": "",
"column_separator": "",
"row_separator": ""
},
"table": {},
"definition_list": {},
"definition_term": {},
"definition_description": {
"block_prefix": "\n🠶 "
"block_prefix": "\n* "
},
"html_block": {},
"html_span": {}
Expand Down
4 changes: 3 additions & 1 deletion styles/tokyo_night.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"bold": true
},
"h1": {
"prefix": "# "
"prefix": "# ",
"bold": true
},
"h2": {
"prefix": "## "
Expand Down Expand Up @@ -142,6 +143,7 @@
},
"name_other": {},
"literal": {},
"literal_number": {},
"literal_date": {},
"literal_string": {
"color": "#e0af68"
Expand Down

0 comments on commit fbf8be6

Please sign in to comment.