@@ -3,7 +3,6 @@ import Foundation
33struct Plist2HTML {
44
55 enum HTMLStyle : String {
6-
76 case light
87 case dark
98 }
@@ -14,59 +13,21 @@ struct Plist2HTML {
1413 self . style = style
1514 }
1615
17- private var textColor : String {
18- return ( self . style == . light) ? self . blackHTMLColor : self . whiteHTMLColor
19- }
20-
21- private var backgroundColor : String {
22- return ( self . style == . light) ? self . whiteHTMLColor : self . blackHTMLColor
23- }
24-
25- private let whiteHTMLColor = " white "
26- private let blackHTMLColor = " black "
27-
28- static let blankLine = " <br> "
29- static let ackKey = " PreferenceSpecifiers "
30- static let titleKey = " Title "
31- static let licenseKey = " License "
32- static let footerKey = " FooterText "
33-
34- func body( with content: String ) -> String {
35- let fullBody = ( " <body style= \" background-color: \( self . backgroundColor) ; \" > " + content + " </body> " )
36-
37- let style = """
38- <style> html, body { font-family: Calibri, \" PT Sans \" ,sans-serif; padding: 15px; }
39- ol {
40- padding-left: 15px;
41- }
42- li {
43- font-size: 16px;
44- }
45- @media (prefers-color-scheme: dark) {
46- body {
47- background: #333;
48- color: #fff;
49- }
50- a {
51- color:#999;
52- }
53- }
54- </style>
55- """
56-
57- return ( fullBody + style)
58- }
16+ private static let whiteHTMLColor = " white "
17+ private static let blackHTMLColor = " black "
5918
60- func header( with title: String ) -> String {
61- return ( " <h1 style= \" color: \( self . textColor) ; \" > " + title + " </h1> " )
62- }
19+ private static let blankLine = " <br> "
20+ private static let ackKey = " PreferenceSpecifiers "
21+ private static let titleKey = " Title "
22+ private static let licenseKey = " License "
23+ private static let footerKey = " FooterText "
6324
64- func subheader ( with subtitle : String ) -> String {
65- return ( " <h3 style= \" color: \( self . textColor ) ; \" > " + subtitle + " </h3> " )
25+ private var textColor : String {
26+ return ( self . style == . light ) ? Plist2HTML . blackHTMLColor : Plist2HTML . whiteHTMLColor
6627 }
6728
68- func paragraph ( with text : String ) -> String {
69- return ( " <p style= \" color: \( self . textColor ) ; \" > " + text + " </p> " )
29+ private var backgroundColor : String {
30+ return ( self . style == . light ) ? Plist2HTML . whiteHTMLColor : Plist2HTML . blackHTMLColor
7031 }
7132
7233 /// Transforms the plist file containing the acknowledgments into an HTML
@@ -103,4 +64,44 @@ struct Plist2HTML {
10364
10465 return self . body ( with: htmlString)
10566 }
67+
68+ // MARK: - Helpers
69+
70+ private func body( with content: String ) -> String {
71+ let fullBody = ( " <body style= \" background-color: \( self . backgroundColor) ; \" > " + content + " </body> " )
72+
73+ let style = """
74+ <style> html, body { font-family: Calibri, " PT Sans " ,sans-serif; padding: 15px; }
75+ ol {
76+ padding-left: 15px;
77+ }
78+ li {
79+ font-size: 16px;
80+ }
81+ @media (prefers-color-scheme: dark) {
82+ body {
83+ background: #333;
84+ color: #fff;
85+ }
86+ a {
87+ color:#999;
88+ }
89+ }
90+ </style>
91+ """
92+
93+ return ( fullBody + style)
94+ }
95+
96+ private func header( with title: String ) -> String {
97+ return ( " <h1 style= \" color: \( self . textColor) ; \" > " + title + " </h1> " )
98+ }
99+
100+ private func subheader( with subtitle: String ) -> String {
101+ return ( " <h3 style= \" color: \( self . textColor) ; \" > " + subtitle + " </h3> " )
102+ }
103+
104+ private func paragraph( with text: String ) -> String {
105+ return ( " <p style= \" color: \( self . textColor) ; \" > " + text + " </p> " )
106+ }
106107}
0 commit comments