28
28
padding : 1em ;
29
29
}
30
30
31
+ /* Class is automatically added to textarea elements, see https://codemirror.net/5/doc/manual.html#styling. */
31
32
.CodeMirror {
32
33
border-radius : 1em ;
33
34
padding : 1em ;
34
35
height : auto;
35
36
}
36
37
37
- select {
38
+ select , input {
38
39
padding : 0.5em ;
39
40
border-radius : 0.2em ;
40
41
}
41
42
43
+ code {
44
+ background : # 4f5a6b ;
45
+ padding : 0.125em 0.25em ;
46
+ }
47
+
42
48
button {
43
49
background : # c2d94c ;
44
50
color : # 0a0e14 ;
@@ -65,7 +71,7 @@ <h1 hidden="hidden">md-to-pdf</h1>
65
71
< label for ="markdown "> Markdown</ label >
66
72
< br >
67
73
< br >
68
- < textarea id ="markdown " class =" markdown " >
74
+ < textarea id ="markdown ">
69
75
# md-to-pdf
70
76
71
77
A web service for converting markdown to PDF
@@ -110,7 +116,7 @@ <h1 hidden="hidden">md-to-pdf</h1>
110
116
< label for ="css "> CSS</ label >
111
117
< br >
112
118
< br >
113
- < textarea id ="css " class =" css " >
119
+ < textarea id ="css ">
114
120
/* You can add some CSS styles too, if you want. */
115
121
116
122
h1, h2 {
@@ -133,14 +139,25 @@ <h1 hidden="hidden">md-to-pdf</h1>
133
139
134
140
< br >
135
141
136
- < label for ="engine "> Conversion Engine (just try which works better for you)</ label >
137
- < br />
138
- < br />
139
- < select id ="engine ">
140
- < option > weasyprint</ option >
141
- < option > wkhtmltopdf</ option >
142
- < option label ="pdflatex (CSS will have no effect) "> pdflatex</ option >
143
- </ select >
142
+ < div style ="display: flex; flex-direction: row; gap: 5em; ">
143
+ < div >
144
+ < label for ="engine "> Conversion Engine (just try which works better for you)</ label >
145
+ < br />
146
+ < br />
147
+ < select id ="engine ">
148
+ < option > weasyprint</ option >
149
+ < option > wkhtmltopdf</ option >
150
+ < option label ="pdflatex (CSS will have no effect) "> pdflatex</ option >
151
+ </ select >
152
+ </ div >
153
+
154
+ < div >
155
+ < label for ="filename "> Filename (defaults to < code > md-to-pdf</ code > , extension < code > .pdf</ code > is always added)</ label >
156
+ < br />
157
+ < br />
158
+ < input type ="text " id ="filename ">
159
+ </ div >
160
+ </ div >
144
161
145
162
< br >
146
163
< br >
@@ -150,11 +167,11 @@ <h1 hidden="hidden">md-to-pdf</h1>
150
167
< script >
151
168
const markdown = CodeMirror . fromTextArea (
152
169
document . querySelector ( '#markdown' ) ,
153
- { mode : 'markdown' , theme : 'ayu-dark' }
170
+ { mode : 'markdown' , theme : 'ayu-dark' } ,
154
171
) ;
155
172
const css = CodeMirror . fromTextArea (
156
173
document . querySelector ( '#css' ) ,
157
- { mode : 'css' , theme : 'ayu-dark' }
174
+ { mode : 'css' , theme : 'ayu-dark' } ,
158
175
) ;
159
176
160
177
async function mdToPdf ( ) {
@@ -179,9 +196,10 @@ <h1 hidden="hidden">md-to-pdf</h1>
179
196
function downloadBlob ( blob ) {
180
197
const url = URL . createObjectURL ( blob ) ;
181
198
const a = document . createElement ( 'a' ) ;
199
+ const filename = document . querySelector ( '#filename' ) . value || 'md-to-pdf'
182
200
183
201
a . href = url ;
184
- a . download = 'md-to-pdf .pdf' ;
202
+ a . download = ` ${ filename } .pdf` ;
185
203
186
204
const clickHandler = ( ) => {
187
205
setTimeout ( ( ) => {
@@ -197,7 +215,9 @@ <h1 hidden="hidden">md-to-pdf</h1>
197
215
198
216
< footer >
199
217
< a href ="https://github.com/spawnia/md-to-pdf " title ="md-to-pdf GitHub repository ">
200
- < svg height ="30 " width ="30 " viewBox ="0 0 16 16 "> < path d ="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z "> </ path > </ svg >
218
+ < svg height ="30 " width ="30 " viewBox ="0 0 16 16 ">
219
+ < path d ="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z "/>
220
+ </ svg >
201
221
</ a >
202
222
</ footer >
203
223
</ body >
0 commit comments