|
44 | 44 | fragment*: bool = false
|
45 | 45 | embed*: bool = true
|
46 | 46 | iso*: bool = false
|
| 47 | + minifycss*: bool = false |
47 | 48 | noclobber*: bool = false
|
48 | 49 | outputToDir*: bool = false
|
49 | 50 | processingMultiple: bool = false
|
|
59 | 60 | snippets: HastySnippets
|
60 | 61 | macros: HastyMacros
|
61 | 62 | document: string
|
| 63 | + hastyStylesheet: string |
62 | 64 | iconStyles: HastyIconStyles
|
63 | 65 | noteStyles: HastyNoteStyles
|
64 | 66 | badgeStyles: HastyBadgeStyles
|
@@ -94,7 +96,18 @@ proc initFields(fields: HastyFields): HastyFields {.gcsafe.} =
|
94 | 96 | result["timezone-offset"] = now.format("zzz")
|
95 | 97 |
|
96 | 98 | proc newHastyScribe*(options: HastyOptions, fields: HastyFields): HastyScribe =
|
97 |
| - return HastyScribe(options: options, fields: initFields(fields), snippets: initTable[string, string](), macros: initTable[string, string](), document: "") |
| 99 | + HastyScribe( |
| 100 | + options: options, |
| 101 | + fields: initFields(fields), |
| 102 | + snippets: initTable[string, string](), |
| 103 | + macros: initTable[string, string](), |
| 104 | + document: "", |
| 105 | + hastyStylesheet: ( |
| 106 | + if not options.embed: "" |
| 107 | + elif options.minifycss: stylesheet.minifyCss() |
| 108 | + else: stylesheet |
| 109 | + ), |
| 110 | + ) |
98 | 111 |
|
99 | 112 | # Utility Procedures
|
100 | 113 |
|
@@ -427,7 +440,7 @@ proc compileDocument*(hs: var HastyScribe, input, dir: string): string {.discard
|
427 | 440 | "<div id=\"header\"><h1>" & metadata.title & "</h1></div>"
|
428 | 441 |
|
429 | 442 | (main_css_tag, optional_css_tag) = if hs.options.embed:
|
430 |
| - (stylesheet.style_tag, hs.create_optional_css(hs.document)) |
| 443 | + (hs.hastyStylesheet.style_tag, hs.create_optional_css(hs.document)) |
431 | 444 | else:
|
432 | 445 | ("", "")
|
433 | 446 |
|
@@ -575,6 +588,7 @@ when isMainModule:
|
575 | 588 | --fragment If specified, an HTML fragment will be generated, without
|
576 | 589 | embedding images or stylesheets.
|
577 | 590 | --iso Use ISO 8601 date format (e.g., 2000-12-31) in the footer.
|
| 591 | + --minify-css, Minify the built-in stylesheet before embedding. |
578 | 592 | --no-clobber, -n Do not overwrite existing files.
|
579 | 593 | --help, -h Display the usage information.
|
580 | 594 | --version, -v Print version and exit."""
|
@@ -623,6 +637,9 @@ when isMainModule:
|
623 | 637 | of "iso":
|
624 | 638 | noVal()
|
625 | 639 | options.iso = true
|
| 640 | + of "minify-css": |
| 641 | + noVal() |
| 642 | + options.minifycss = true |
626 | 643 | of "n", "no-clobber", "noclobber":
|
627 | 644 | noVal()
|
628 | 645 | options.noclobber = true
|
|
0 commit comments