Skip to content

Commit

Permalink
Bake-in Dracula (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
meowgorithm committed Jan 23, 2022
1 parent 39ee7f3 commit 94148ad
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 15 deletions.
218 changes: 218 additions & 0 deletions dracula.go
@@ -0,0 +1,218 @@
package glamour

import "github.com/charmbracelet/glamour/ansi"

var DraculaStyleConfig = ansi.StyleConfig{
Document: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
BlockPrefix: "\n",
BlockSuffix: "\n",
Color: stringPtr("#f8f8f2"),
},
Margin: uintPtr(2),
},
BlockQuote: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#f1fa8c"),
Italic: boolPtr(true),
},
Indent: uintPtr(2),
},
List: ansi.StyleList{
LevelIndent: 2,
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#f8f8f2"),
},
},
},
Heading: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
BlockSuffix: "\n",
Color: stringPtr("#bd93f9"),
Bold: boolPtr(true),
},
},
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{
CrossedOut: boolPtr(true),
},
Emph: ansi.StylePrimitive{
Color: stringPtr("#f1fa8c"),
Italic: boolPtr(true),
},
Strong: ansi.StylePrimitive{
Bold: boolPtr(true),
Color: stringPtr("#ffb86c"),
},
HorizontalRule: ansi.StylePrimitive{
Color: stringPtr("#6272A4"),
Format: "\n--------\n",
},
Item: ansi.StylePrimitive{
BlockPrefix: "• ",
},
Enumeration: ansi.StylePrimitive{
BlockPrefix: ". ",
Color: stringPtr("#8be9fd"),
},
Task: ansi.StyleTask{
StylePrimitive: ansi.StylePrimitive{},
Ticked: "[✓] ",
Unticked: "[ ] ",
},
Link: ansi.StylePrimitive{
Color: stringPtr("#8be9fd"),
Underline: boolPtr(true),
},
LinkText: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
},
Image: ansi.StylePrimitive{
Color: stringPtr("#8be9fd"),
Underline: boolPtr(true),
},
ImageText: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
Format: "Image: {{.text}} →",
},
Code: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#50fa7b"),
},
},
CodeBlock: ansi.StyleCodeBlock{
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#ffb86c"),
},
Margin: uintPtr(2),
},
Chroma: &ansi.Chroma{
Text: ansi.StylePrimitive{
Color: stringPtr("#f8f8f2"),
},
Error: ansi.StylePrimitive{
Color: stringPtr("#f8f8f2"),
BackgroundColor: stringPtr("#ff5555"),
},
Comment: ansi.StylePrimitive{
Color: stringPtr("#6272A4"),
},
CommentPreproc: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
},
Keyword: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
},
KeywordReserved: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
},
KeywordNamespace: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
},
KeywordType: ansi.StylePrimitive{
Color: stringPtr("#8be9fd"),
},
Operator: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
},
Punctuation: ansi.StylePrimitive{
Color: stringPtr("#f8f8f2"),
},
Name: ansi.StylePrimitive{
Color: stringPtr("#8be9fd"),
},
NameBuiltin: ansi.StylePrimitive{
Color: stringPtr("#8be9fd"),
},
NameTag: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
},
NameAttribute: ansi.StylePrimitive{
Color: stringPtr("#50fa7b"),
},
NameClass: ansi.StylePrimitive{
Color: stringPtr("#8be9fd"),
},
NameConstant: ansi.StylePrimitive{
Color: stringPtr("#bd93f9"),
},
NameDecorator: ansi.StylePrimitive{
Color: stringPtr("#50fa7b"),
},
NameFunction: ansi.StylePrimitive{
Color: stringPtr("#50fa7b"),
},
LiteralNumber: ansi.StylePrimitive{
Color: stringPtr("#6EEFC0"),
},
LiteralString: ansi.StylePrimitive{
Color: stringPtr("#f1fa8c"),
},
LiteralStringEscape: ansi.StylePrimitive{
Color: stringPtr("#ff79c6"),
},
GenericDeleted: ansi.StylePrimitive{
Color: stringPtr("#ff5555"),
},
GenericEmph: ansi.StylePrimitive{
Color: stringPtr("#f1fa8c"),
Italic: boolPtr(true),
},
GenericInserted: ansi.StylePrimitive{
Color: stringPtr("#50fa7b"),
},
GenericStrong: ansi.StylePrimitive{
Color: stringPtr("#ffb86c"),
Bold: boolPtr(true),
},
GenericSubheading: ansi.StylePrimitive{
Color: stringPtr("#bd93f9"),
},
Background: ansi.StylePrimitive{
BackgroundColor: stringPtr("#282a36"),
},
},
},
Table: ansi.StyleTable{
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{},
},
CenterSeparator: stringPtr("┼"),
ColumnSeparator: stringPtr("│"),
RowSeparator: stringPtr("─"),
},
DefinitionDescription: ansi.StylePrimitive{
BlockPrefix: "\n🠶 ",
},
}
9 changes: 5 additions & 4 deletions styles.go
Expand Up @@ -648,10 +648,11 @@ var (

// DefaultStyles are the default styles.
DefaultStyles = map[string]*ansi.StyleConfig{
"ascii": &ASCIIStyleConfig,
"dark": &DarkStyleConfig,
"light": &LightStyleConfig,
"notty": &NoTTYStyleConfig,
"ascii": &ASCIIStyleConfig,
"dark": &DarkStyleConfig,
"light": &LightStyleConfig,
"notty": &NoTTYStyleConfig,
"dracula": &DraculaStyleConfig,
}
)

Expand Down
21 changes: 10 additions & 11 deletions styles/dracula.json
Expand Up @@ -6,14 +6,14 @@
"margin": 2
},
"block_quote": {
"indent": 2,
"color": "#f1fa8c",
"italic": true
"italic": true,
"indent": 2
},
"paragraph": {},
"list": {
"level_indent": 2,
"color": "#f8f8f2"
"color": "#f8f8f2",
"level_indent": 2
},
"heading": {
"block_suffix": "\n",
Expand Down Expand Up @@ -43,12 +43,12 @@
"crossed_out": true
},
"emph": {
"italic": true,
"color": "#f1fa8c"
"color": "#f1fa8c",
"italic": true
},
"strong": {
"bold": true,
"color": "#ffb86c"
"color": "#ffb86c",
"bold": true
},
"hr": {
"color": "#6272A4",
Expand Down Expand Up @@ -134,7 +134,7 @@
"color": "#8be9fd"
},
"name_constant": {
"color": "#bd93f9"
"color": "#bd93f9"
},
"name_decorator": {
"color": "#50fa7b"
Expand Down Expand Up @@ -170,8 +170,7 @@
"bold": true
},
"generic_subheading": {
"color": "#bd93f9",
"color": "#777777"
"color": "#bd93f9"
},
"background": {
"background_color": "#282a36"
Expand Down
4 changes: 4 additions & 0 deletions styles/gallery/README.md
Expand Up @@ -13,3 +13,7 @@
Pronounced _naughty_.

![Glamour NoTTY Style](https://github.com/charmbracelet/glamour/raw/master/styles/gallery/notty.png)

## Dracula

![Dracula Style](https://github.com/charmbracelet/glamour/raw/master/styles/gallery/dracula.png)
Binary file added styles/gallery/dracula.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 94148ad

Please sign in to comment.