Kaynağa Gözat

Prettying up the JS markdown CSS

main
Rocketsoup 1 yıl önce
ebeveyn
işleme
eb7cf669ea
3 değiştirilmiş dosya ile 131 ekleme ve 11 silme
  1. 12
    6
      js/markdown.js
  2. 1
    1
      js/markdown.min.js
  3. 118
    4
      markdownjs.html

+ 12
- 6
js/markdown.js Dosyayı Görüntüle

3113
 		return this.original;
3113
 		return this.original;
3114
 	}
3114
 	}
3115
 
3115
 
3116
+	static #styleToObject(styleValue) {
3117
+		const pairs = styleValue.split(';');
3118
+		var styles = {};
3119
+		for (const pair of pairs) {
3120
+			const keyAndValue = pair.split(':');
3121
+			if (keyAndValue.length != 2) continue;
3122
+			styles[keyAndValue[0]] = keyAndValue[1];
3123
+		}
3124
+		return styles;
3125
+	}
3126
+
3116
 	static #fromContents(contents) {
3127
 	static #fromContents(contents) {
3117
 		let modifierTokens = contents.split(/\s+/);
3128
 		let modifierTokens = contents.split(/\s+/);
3118
 		let mod = new MDTagModifier();
3129
 		let mod = new MDTagModifier();
3126
 				mod.cssId = groups[1];
3137
 				mod.cssId = groups[1];
3127
 			} else if (groups = this.#attributeRegex.exec(token)) {
3138
 			} else if (groups = this.#attributeRegex.exec(token)) {
3128
 				if (groups[1] == 'style') {
3139
 				if (groups[1] == 'style') {
3129
-					const pairs = groups[2].split(';');
3130
-					for (const pair of pairs) {
3131
-						const keyValue = pair.split(':');
3132
-						if (keyValue.length != 2) continue;
3133
-						mod.cssStyles[keyValue[0]] = keyValue[1];
3134
-					}
3140
+					mod.cssStyles = this.#styleToObject(groups[2]);
3135
 				} else {
3141
 				} else {
3136
 					mod.attributes[groups[1]] = groups[2];
3142
 					mod.attributes[groups[1]] = groups[2];
3137
 				}
3143
 				}

+ 1
- 1
js/markdown.min.js
Dosya farkı çok büyük olduğundan ihmal edildi
Dosyayı Görüntüle


+ 118
- 4
markdownjs.html Dosyayı Görüntüle

6
 		<link rel="icon" href="data:;base64,iVBORw0KGgo=">
6
 		<link rel="icon" href="data:;base64,iVBORw0KGgo=">
7
 		<style type="text/css">
7
 		<style type="text/css">
8
 			:root {
8
 			:root {
9
-				--color-background: white;
10
-				--color-text: black;
9
+				--color-background: #fffff8;
10
+				--color-text: #111;
11
 				--color-editor-background: #0000aa;
11
 				--color-editor-background: #0000aa;
12
 				--color-editor-text: white;
12
 				--color-editor-text: white;
13
 				--color-table-header: #ddd;
13
 				--color-table-header: #ddd;
22
 				background-color: var(--color-background);
22
 				background-color: var(--color-background);
23
 				color: var(--color-text);
23
 				color: var(--color-text);
24
 			}
24
 			}
25
+/* body {
26
+    width: 87.5%;
27
+    margin-left: auto;
28
+    margin-right: auto;
29
+    padding-left: 12.5%;
30
+    background-color: #fffff8;
31
+    color: #111;
32
+    max-width: 1400px;
33
+    counter-reset: sidenote-counter;
34
+} */
25
 			.inputhalf {
35
 			.inputhalf {
26
 				position: absolute;
36
 				position: absolute;
27
 				width: 50%;
37
 				width: 50%;
75
 			}
85
 			}
76
 			@media (prefers-color-scheme: dark) {
86
 			@media (prefers-color-scheme: dark) {
77
 				:root {
87
 				:root {
78
-					--color-background: black;
79
-					--color-text: white;
88
+					--color-background: #151515;
89
+					--color-text: #ddd;
80
 					--color-table-header: #333;
90
 					--color-table-header: #333;
81
 					--color-table-border: #ccc;
91
 					--color-table-border: #ccc;
82
 					--color-calculated-background: #444;
92
 					--color-calculated-background: #444;
83
 				}
93
 				}
84
 			}
94
 			}
85
 		</style>
95
 		</style>
96
+		<style type="text/css">
97
+			/* From https://github.com/edwardtufte/tufte-css/blob/gh-pages/tufte.css */
98
+			html {
99
+				font-size: 15px;
100
+			}
101
+
102
+			body {
103
+				/* width: 87.5%;
104
+				margin-left: auto;
105
+				margin-right: auto;
106
+				padding-left: 12.5%; */
107
+				font-family: et-book, Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
108
+				background-color: #fffff8;
109
+				color: #111;
110
+				/* max-width: 1400px; */
111
+				counter-reset: sidenote-counter;
112
+			}
113
+
114
+			/* Adds dark mode */
115
+			@media (prefers-color-scheme: dark) {
116
+				body {
117
+					background-color: #151515;
118
+					color: #ddd;
119
+				}
120
+			}
121
+			h1 {
122
+				font-weight: 400;
123
+				margin-top: 4rem;
124
+				margin-bottom: 1.5rem;
125
+				font-size: 3.2rem;
126
+				line-height: 1;
127
+			}
128
+			h2 {
129
+				font-style: italic;
130
+				font-weight: 400;
131
+				margin-top: 2.1rem;
132
+				margin-bottom: 1.4rem;
133
+				font-size: 2.2rem;
134
+				line-height: 1;
135
+			}
136
+			h3 {
137
+				font-style: italic;
138
+				font-weight: 400;
139
+				font-size: 1.7rem;
140
+				margin-top: 2rem;
141
+				margin-bottom: 1.4rem;
142
+				line-height: 1;
143
+			}
144
+			hr {
145
+				display: block;
146
+				height: 1px;
147
+				width: 55%;
148
+				border: 0;
149
+				border-top: 1px solid #ccc;
150
+				margin: 1em 0;
151
+				padding: 0;
152
+			}
153
+			article {
154
+				padding: 5rem 0rem;
155
+			}
156
+			section {
157
+				padding-top: 1rem;
158
+				padding-bottom: 1rem;
159
+			}
160
+			p,
161
+			dl,
162
+			ol,
163
+			ul {
164
+				font-size: 1.4rem;
165
+				line-height: 2rem;
166
+			}
167
+			p.subtitle {
168
+				font-style: italic;
169
+				margin-top: 1rem;
170
+				margin-bottom: 1rem;
171
+				font-size: 1.8rem;
172
+				display: block;
173
+				line-height: 1;
174
+			}
175
+			code, pre > code {
176
+				font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
177
+				font-size: 1.0rem;
178
+				line-height: 1.42;
179
+				-webkit-text-size-adjust: 100%; /* Prevent adjustments of font size after orientation changes in iOS. See https://github.com/edwardtufte/tufte-css/issues/81#issuecomment-261953409 */
180
+			}
181
+			pre > code {
182
+				font-size: 0.9rem;
183
+				width: 52.5%;
184
+				margin-left: 2.5%;
185
+				overflow-x: auto;
186
+				display: block;
187
+			}
188
+			a:link,
189
+			a:visited {
190
+				color: inherit;
191
+				text-underline-offset: 0.1em;
192
+				text-decoration-thickness: 0.05em;
193
+			}
194
+			dt:not(:first-child),
195
+			li:not(:first-child) {
196
+				margin-top: 0.25rem;
197
+			}
198
+
199
+		</style>
86
 		<script src="js/markdown.js"></script>
200
 		<script src="js/markdown.js"></script>
87
 		<script src="js/spreadsheet.js"></script>
201
 		<script src="js/spreadsheet.js"></script>
88
 		<script>
202
 		<script>

Loading…
İptal
Kaydet