Generate example styles from default styles

This commit is contained in:
Tom Payne
2020-01-05 05:45:40 +01:00
committed by Christian Muehlhaeuser
parent 6b9278b445
commit bdbe6ae0c5
6 changed files with 233 additions and 175 deletions
+38
View File
@@ -0,0 +1,38 @@
package main
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/glamour/ansi"
)
func writeStyleJSON(filename string, styleConfig *ansi.StyleConfig) error {
f, err := os.Create(filename)
if err != nil {
return err
}
defer f.Close()
e := json.NewEncoder(f)
e.SetIndent("", " ")
return e.Encode(styleConfig)
}
func run() error {
for style, styleConfig := range glamour.DefaultStyles {
if err := writeStyleJSON(filepath.Join("styles", style+".json"), styleConfig); err != nil {
return err
}
}
return nil
}
func main() {
if err := run(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
+5
View File
@@ -1,5 +1,10 @@
# Glamour Style Guide # Glamour Style Guide
The JSON files in this directory are generated from the default styles. To
re-generate them, run:
go run ./internal/generate-style-json
## Block Elements ## Block Elements
Block elements contain other elements and are rendered around them. All block Block elements contain other elements and are rendered around them. All block
+63 -57
View File
@@ -1,9 +1,17 @@
{ {
"document": { "document": {
"indent": 2,
"block_prefix": "\n", "block_prefix": "\n",
"block_suffix": "\n", "block_suffix": "\n",
"color": "252" "color": "252",
"indent": 2
},
"block_quote": {
"indent": 1,
"indent_token": "│ "
},
"paragraph": {},
"list": {
"level_indent": 2
}, },
"heading": { "heading": {
"block_suffix": "\n", "block_suffix": "\n",
@@ -13,8 +21,8 @@
"h1": { "h1": {
"prefix": " ", "prefix": " ",
"suffix": " ", "suffix": " ",
"background_color": "63",
"color": "228", "color": "228",
"background_color": "63",
"bold": true "bold": true
}, },
"h2": { "h2": {
@@ -35,40 +43,6 @@
"bold": false "bold": false
}, },
"text": {}, "text": {},
"list": {
"level_indent": 2
},
"item": {
"block_prefix": "• "
},
"enumeration": {
"block_prefix": ". "
},
"link_text": {
"color": "35",
"bold": true
},
"link": {
"underline": true,
"color": "30"
},
"image_text": {
"format": "Image: {{.text}} →",
"color": "243"
},
"image": {
"underline": true,
"color": "212"
},
"table": {
"center_separator": "┼",
"column_separator": "│",
"row_separator": "─"
},
"task": {
"unticked": "[ ] ",
"ticked": "[✓] "
},
"strikethrough": { "strikethrough": {
"crossed_out": true "crossed_out": true
}, },
@@ -79,29 +53,44 @@
"bold": true "bold": true
}, },
"hr": { "hr": {
"format": "\n--------\n", "color": "240",
"color": "240" "format": "\n--------\n"
}, },
"block_quote": { "item": {
"indent": 1, "block_prefix": "• "
"indent_token": "│ "
}, },
"definition_list": {}, "enumeration": {
"definition_term": {}, "block_prefix": ". "
"definition_description": { },
"block_prefix": "\n🠶 " "task": {
"ticked": "[✓] ",
"unticked": "[ ] "
},
"link": {
"color": "30",
"underline": true
},
"link_text": {
"color": "35",
"bold": true
},
"image": {
"color": "212",
"underline": true
},
"image_text": {
"color": "243",
"format": "Image: {{.text}} →"
}, },
"html_block": {},
"html_span": {},
"code": { "code": {
"prefix": " ", "prefix": " ",
"suffix": " ", "suffix": " ",
"background_color": "236", "color": "203",
"color": "203" "background_color": "236"
}, },
"code_block": { "code_block": {
"margin": 2,
"color": "244", "color": "244",
"margin": 2,
"chroma": { "chroma": {
"text": { "text": {
"color": "#C4C4C4" "color": "#C4C4C4"
@@ -148,18 +137,23 @@
}, },
"name_class": { "name_class": {
"color": "#F1F1F1", "color": "#F1F1F1",
"bold": true, "underline": true,
"underline": true "bold": true
}, },
"name_constant": {},
"name_decorator": { "name_decorator": {
"color": "#FFFF87" "color": "#FFFF87"
}, },
"name_exception": {},
"name_function": { "name_function": {
"color": "#00D787" "color": "#00D787"
}, },
"name_other": {},
"literal": {},
"literal_number": { "literal_number": {
"color": "#6EEFC0" "color": "#6EEFC0"
}, },
"literal_date": {},
"literal_string": { "literal_string": {
"color": "#C69669" "color": "#C69669"
}, },
@@ -172,12 +166,12 @@
"generic_emph": { "generic_emph": {
"italic": true "italic": true
}, },
"generic_strong": {
"bold": true
},
"generic_inserted": { "generic_inserted": {
"color": "#00D787" "color": "#00D787"
}, },
"generic_strong": {
"bold": true
},
"generic_subheading": { "generic_subheading": {
"color": "#777777" "color": "#777777"
}, },
@@ -185,5 +179,17 @@
"background_color": "#373737" "background_color": "#373737"
} }
} }
} },
"table": {
"center_separator": "┼",
"column_separator": "│",
"row_separator": "─"
},
"definition_list": {},
"definition_term": {},
"definition_description": {
"block_prefix": "\n🠶 "
},
"html_block": {},
"html_span": {}
} }
+63 -57
View File
@@ -1,9 +1,17 @@
{ {
"document": { "document": {
"indent": 2,
"block_prefix": "\n", "block_prefix": "\n",
"block_suffix": "\n", "block_suffix": "\n",
"color": "234" "color": "234",
"indent": 2
},
"block_quote": {
"indent": 1,
"indent_token": "│ "
},
"paragraph": {},
"list": {
"level_indent": 2
}, },
"heading": { "heading": {
"block_suffix": "\n", "block_suffix": "\n",
@@ -13,8 +21,8 @@
"h1": { "h1": {
"prefix": " ", "prefix": " ",
"suffix": " ", "suffix": " ",
"background_color": "63",
"color": "228", "color": "228",
"background_color": "63",
"bold": true "bold": true
}, },
"h2": { "h2": {
@@ -34,40 +42,6 @@
"bold": false "bold": false
}, },
"text": {}, "text": {},
"list": {
"level_indent": 2
},
"item": {
"block_prefix": "• "
},
"enumeration": {
"block_prefix": ". "
},
"link_text": {
"color": "29",
"bold": true
},
"link": {
"underline": true,
"color": "36"
},
"image_text": {
"format": "Image: {{.text}} →",
"color": "243"
},
"image": {
"underline": true,
"color": "205"
},
"table": {
"center_separator": "┼",
"column_separator": "│",
"row_separator": "─"
},
"task": {
"unticked": "[ ] ",
"ticked": "[✓] "
},
"strikethrough": { "strikethrough": {
"crossed_out": true "crossed_out": true
}, },
@@ -78,29 +52,44 @@
"bold": true "bold": true
}, },
"hr": { "hr": {
"format": "\n--------\n", "color": "249",
"color": "249" "format": "\n--------\n"
}, },
"block_quote": { "item": {
"indent": 1, "block_prefix": "• "
"indent_token": "│ "
}, },
"definition_list": {}, "enumeration": {
"definition_term": {}, "block_prefix": ". "
"definition_description": { },
"block_prefix": "\n🠶 " "task": {
"ticked": "[✓] ",
"unticked": "[ ] "
},
"link": {
"color": "36",
"underline": true
},
"link_text": {
"color": "29",
"bold": true
},
"image": {
"color": "205",
"underline": true
},
"image_text": {
"color": "243",
"format": "Image: {{.text}} →"
}, },
"html_block": {},
"html_span": {},
"code": { "code": {
"prefix": " ", "prefix": " ",
"suffix": " ", "suffix": " ",
"background_color": "254", "color": "203",
"color": "203" "background_color": "254"
}, },
"code_block": { "code_block": {
"margin": 2,
"color": "242", "color": "242",
"margin": 2,
"chroma": { "chroma": {
"text": { "text": {
"color": "#2A2A2A" "color": "#2A2A2A"
@@ -133,6 +122,7 @@
"punctuation": { "punctuation": {
"color": "#FA7878" "color": "#FA7878"
}, },
"name": {},
"name_builtin": { "name_builtin": {
"color": "#0A1BB1" "color": "#0A1BB1"
}, },
@@ -144,8 +134,8 @@
}, },
"name_class": { "name_class": {
"color": "#212121", "color": "#212121",
"bold": true, "underline": true,
"underline": true "bold": true
}, },
"name_constant": { "name_constant": {
"color": "#581290" "color": "#581290"
@@ -153,12 +143,16 @@
"name_decorator": { "name_decorator": {
"color": "#A3A322" "color": "#A3A322"
}, },
"name_exception": {},
"name_function": { "name_function": {
"color": "#019F57" "color": "#019F57"
}, },
"name_other": {},
"literal": {},
"literal_number": { "literal_number": {
"color": "#22CCAE" "color": "#22CCAE"
}, },
"literal_date": {},
"literal_string": { "literal_string": {
"color": "#7E5B38" "color": "#7E5B38"
}, },
@@ -171,12 +165,12 @@
"generic_emph": { "generic_emph": {
"italic": true "italic": true
}, },
"generic_strong": {
"bold": true
},
"generic_inserted": { "generic_inserted": {
"color": "#00D787" "color": "#00D787"
}, },
"generic_strong": {
"bold": true
},
"generic_subheading": { "generic_subheading": {
"color": "#777777" "color": "#777777"
}, },
@@ -184,5 +178,17 @@
"background_color": "#373737" "background_color": "#373737"
} }
} }
} },
"table": {
"center_separator": "┼",
"column_separator": "│",
"row_separator": "─"
},
"definition_list": {},
"definition_term": {},
"definition_description": {
"block_prefix": "\n🠶 "
},
"html_block": {},
"html_span": {}
} }
+38 -37
View File
@@ -1,8 +1,16 @@
{ {
"document": { "document": {
"indent": 2,
"block_prefix": "\n", "block_prefix": "\n",
"block_suffix": "\n" "block_suffix": "\n",
"indent": 2
},
"block_quote": {
"indent": 1,
"indent_token": "│ "
},
"paragraph": {},
"list": {
"level_indent": 4
}, },
"heading": { "heading": {
"block_suffix": "\n" "block_suffix": "\n"
@@ -26,30 +34,6 @@
"prefix": "###### " "prefix": "###### "
}, },
"text": {}, "text": {},
"list": {
"level_indent": 4
},
"item": {
"block_prefix": "• "
},
"enumeration": {
"block_prefix": ". "
},
"link_text": {},
"link": {},
"image_text": {
"format": "Image: {{.text}} →"
},
"image": {},
"table": {
"center_separator": "┼",
"column_separator": "│",
"row_separator": "─"
},
"task": {
"unticked": "[ ] ",
"ticked": "[✓] "
},
"strikethrough": { "strikethrough": {
"block_prefix": "~~", "block_prefix": "~~",
"block_suffix": "~~" "block_suffix": "~~"
@@ -65,9 +49,33 @@
"hr": { "hr": {
"format": "\n--------\n" "format": "\n--------\n"
}, },
"block_quote": { "item": {
"indent": 1, "block_prefix": "• "
"indent_token": "│ " },
"enumeration": {
"block_prefix": ". "
},
"task": {
"ticked": "[✓] ",
"unticked": "[ ] "
},
"link": {},
"link_text": {},
"image": {},
"image_text": {
"format": "Image: {{.text}} →"
},
"code": {
"block_prefix": "`",
"block_suffix": "`"
},
"code_block": {
"margin": 2
},
"table": {
"center_separator": "┼",
"column_separator": "│",
"row_separator": "─"
}, },
"definition_list": {}, "definition_list": {},
"definition_term": {}, "definition_term": {},
@@ -75,12 +83,5 @@
"block_prefix": "\n🠶 " "block_prefix": "\n🠶 "
}, },
"html_block": {}, "html_block": {},
"html_span": {}, "html_span": {}
"code": {
"block_prefix": "`",
"block_suffix": "`"
},
"code_block": {
"margin": 2
}
} }
+26 -24
View File
@@ -1,5 +1,13 @@
{ {
"document": {}, "document": {},
"block_quote": {
"indent": 1,
"indent_token": "\u003e "
},
"paragraph": {},
"list": {
"level_indent": 4
},
"heading": { "heading": {
"block_suffix": "\n" "block_suffix": "\n"
}, },
@@ -23,27 +31,6 @@
"prefix": "###### " "prefix": "###### "
}, },
"text": {}, "text": {},
"list": {
"level_indent": 4
},
"item": {
"block_prefix": "- "
},
"enumeration": {
"block_prefix": ". "
},
"link_text": {},
"link": {},
"image_text": {
"format": "Image: {{.text}} => "
},
"image": {},
"code": {
"block_prefix": "`",
"block_suffix": "`"
},
"code_block": {},
"table": {},
"strikethrough": { "strikethrough": {
"block_prefix": "~~", "block_prefix": "~~",
"block_suffix": "~~" "block_suffix": "~~"
@@ -59,10 +46,25 @@
"hr": { "hr": {
"format": "\n--------\n" "format": "\n--------\n"
}, },
"block_quote": { "item": {
"indent": 1, "block_prefix": "- "
"indent_token": "> "
}, },
"enumeration": {
"block_prefix": ". "
},
"task": {},
"link": {},
"link_text": {},
"image": {},
"image_text": {
"format": "Image: {{.text}} =\u003e "
},
"code": {
"block_prefix": "`",
"block_suffix": "`"
},
"code_block": {},
"table": {},
"definition_list": {}, "definition_list": {},
"definition_term": {}, "definition_term": {},
"definition_description": { "definition_description": {