Skip to content

Commit 50052ec

Browse files
committed
Format with npm run prettier -- --write
1 parent d6b4013 commit 50052ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1755
-3356
lines changed

docs/generate.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,52 +16,52 @@ const styles = {
1616
h1: {
1717
font: 'fonts/Alegreya-Bold.ttf',
1818
fontSize: 25,
19-
padding: 15
19+
padding: 15,
2020
},
2121
h2: {
2222
font: 'fonts/Alegreya-Bold.ttf',
2323
fontSize: 18,
24-
padding: 10
24+
padding: 10,
2525
},
2626
h3: {
2727
font: 'fonts/Alegreya-Bold.ttf',
2828
fontSize: 18,
29-
padding: 10
29+
padding: 10,
3030
},
3131
para: {
3232
font: 'fonts/Merriweather-Regular.ttf',
3333
fontSize: 10,
34-
padding: 10
34+
padding: 10,
3535
},
3636
code: {
3737
font: 'fonts/SourceCodePro-Regular.ttf',
38-
fontSize: 9
38+
fontSize: 9,
3939
},
4040
code_block: {
4141
padding: 10,
42-
background: '#2c2c2c'
42+
background: '#2c2c2c',
4343
},
4444
inlinecode: {
4545
font: 'fonts/SourceCodePro-Bold.ttf',
46-
fontSize: 10
46+
fontSize: 10,
4747
},
4848
listitem: {
4949
font: 'fonts/Merriweather-Regular.ttf',
5050
fontSize: 10,
51-
padding: 6
51+
padding: 6,
5252
},
5353
link: {
5454
font: 'fonts/Merriweather-Regular.ttf',
5555
fontSize: 10,
5656
color: 'blue',
57-
underline: true
57+
underline: true,
5858
},
5959
example: {
6060
font: 'Helvetica',
6161
fontSize: 9,
6262
color: 'black',
63-
padding: 10
64-
}
63+
padding: 10,
64+
},
6565
};
6666

6767
// syntax highlighting colors
@@ -89,7 +89,7 @@ const colors = {
8989
quote: '#93a1a1',
9090
link: '#93a1a1',
9191
special: '#6c71c4',
92-
default: '#002b36'
92+
default: '#002b36',
9393
};
9494

9595
// shared lorem ipsum text so we don't need to copy it into every example
@@ -135,7 +135,7 @@ class Node {
135135
const color = colors[style] || colors.default;
136136
const opts = {
137137
color,
138-
continued: text !== '\n'
138+
continued: text !== '\n',
139139
};
140140

141141
return this.content.push(new Node(['code', opts, text]));
@@ -164,7 +164,7 @@ class Node {
164164
}
165165

166166
// sets the styles on the document for this node
167-
setStyle (doc) {
167+
setStyle(doc) {
168168
if (this.style.font) {
169169
doc.font(this.style.font);
170170
}
@@ -189,7 +189,7 @@ class Node {
189189
}
190190

191191
// renders this node and its subnodes to the document
192-
render (doc, continued) {
192+
render(doc, continued) {
193193
let y;
194194
if (continued == null) {
195195
continued = false;
@@ -210,7 +210,7 @@ class Node {
210210
// run the example code with the document
211211
vm.runInNewContext(this.code, {
212212
doc,
213-
lorem
213+
lorem,
214214
});
215215

216216
// restore points and styles
@@ -257,7 +257,7 @@ class Node {
257257
} else {
258258
fragment.render(
259259
doc,
260-
index < this.content.length - 1 && this.type !== 'bulletlist'
260+
index < this.content.length - 1 && this.type !== 'bulletlist',
261261
);
262262
}
263263

@@ -286,7 +286,7 @@ const render = (doc, filename) => {
286286
};
287287

288288
// renders the title page of the guide
289-
const renderTitlePage = doc => {
289+
const renderTitlePage = (doc) => {
290290
const title = 'PDFKit Guide';
291291
const author = 'By Devon Govett';
292292
const version = `Version ${require('../package.json').version}`;
@@ -301,13 +301,13 @@ const renderTitlePage = doc => {
301301
doc.y -= 10;
302302
doc.text(author, {
303303
align: 'center',
304-
indent: w - doc.widthOfString(author)
304+
indent: w - doc.widthOfString(author),
305305
});
306306

307307
doc.font(styles.para.font, 10);
308308
doc.text(version, {
309309
align: 'center',
310-
indent: w - doc.widthOfString(version)
310+
indent: w - doc.widthOfString(version),
311311
});
312312

313313
doc.addPage();

docs/generate_website.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ const files = [
2424
'destinations.md',
2525
'attachments.md',
2626
'accessibility.md',
27-
'you_made_it.md'
27+
'you_made_it.md',
2828
];
2929

3030
// shared lorem ipsum text so we don't need to copy it into every example
3131
const lorem =
3232
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in suscipit purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus nec hendrerit felis. Morbi aliquam facilisis risus eu lacinia. Sed eu leo in turpis fringilla hendrerit. Ut nec accumsan nisl. Suspendisse rhoncus nisl posuere tortor tempus et dapibus elit porta. Cras leo neque, elementum a rhoncus ut, vestibulum non nibh. Phasellus pretium justo turpis. Etiam vulputate, odio vitae tincidunt ultricies, eros odio dapibus nisi, ut tincidunt lacus arcu eu elit. Aenean velit erat, vehicula eget lacinia ut, dignissim non tellus. Aliquam nec lacus mi, sed vestibulum nunc. Suspendisse potenti. Curabitur vitae sem turpis. Vestibulum sed neque eget dolor dapibus porttitor at sit amet sem. Fusce a turpis lorem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;';
3333

34-
const getNodeName = function(node) {
34+
const getNodeName = function (node) {
3535
if (node.length === 3) {
3636
return node[2];
3737
}
@@ -48,7 +48,7 @@ const getNodeName = function(node) {
4848
return words.join('');
4949
};
5050

51-
const extractHeaders = function(tree) {
51+
const extractHeaders = function (tree) {
5252
const headers = [];
5353

5454
for (let index = 0; index < tree.length; index++) {
@@ -62,7 +62,7 @@ const extractHeaders = function(tree) {
6262
node[1].id = hash;
6363
headers.push({
6464
hash,
65-
title: name
65+
title: name,
6666
});
6767
}
6868
}
@@ -71,7 +71,7 @@ const extractHeaders = function(tree) {
7171
};
7272

7373
let imageIndex = 0;
74-
const generateImages = function(tree) {
74+
const generateImages = function (tree) {
7575
// find code blocks
7676
const codeBlocks = [];
7777
for (var node of tree) {
@@ -99,7 +99,7 @@ const generateImages = function(tree) {
9999

100100
vm.runInNewContext(code, {
101101
doc,
102-
lorem
102+
lorem,
103103
});
104104

105105
delete attrs.title;
@@ -118,7 +118,7 @@ const generateImages = function(tree) {
118118
console.error(err);
119119
}
120120
fs.unlinkSync(`${f}.pdf`);
121-
}
121+
},
122122
);
123123
});
124124

@@ -134,7 +134,7 @@ for (let file of Array.from(files)) {
134134
// turn github highlighted code blocks into normal markdown code blocks
135135
content = content.replace(
136136
/^```javascript\n((:?.|\n)*?)\n```/gm,
137-
(m, $1) => ` ${$1.split('\n').join('\n ')}`
137+
(m, $1) => ` ${$1.split('\n').join('\n ')}`,
138138
);
139139

140140
const tree = markdown.parse(content);
@@ -148,7 +148,7 @@ for (let file of Array.from(files)) {
148148
url: `/docs/${file}.html`,
149149
title: headers[0].title,
150150
headers: headers.slice(1),
151-
content: markdown.toHTML(tree)
151+
content: markdown.toHTML(tree),
152152
});
153153
}
154154

docs/publish_website.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ ghpages.publish(
1414
'docs/guide.pdf',
1515
'examples/browserify/browser.html',
1616
'examples/browserify/bundle.js',
17-
'examples/kitchen-sink.pdf'
17+
'examples/kitchen-sink.pdf',
1818
],
1919
add: true,
20-
message
20+
message,
2121
},
22-
function(err) {
22+
function (err) {
2323
if (err) {
2424
console.error(err);
2525
}
26-
}
26+
},
2727
);

examples/attachment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ doc.info['Title'] = 'Attachment Test';
1212
doc.file(path.join(__dirname, 'images', 'test.png'), {
1313
name: 'test.png',
1414
type: 'image/png',
15-
description: 'this is a test image'
15+
description: 'this is a test image',
1616
});
1717

1818
// add some text
@@ -26,7 +26,7 @@ hover over the paperclip to see its description!`);
2626
const file = {
2727
src: Buffer.from('buffered input!'),
2828
name: 'embedded.txt',
29-
creationDate: new Date(2020, 3, 1)
29+
creationDate: new Date(2020, 3, 1),
3030
};
3131
// then, add the annotation
3232
doc.fileAnnotation(100, 150, 10, doc.currentLineHeight(), file);
@@ -36,7 +36,7 @@ doc.fileAnnotation(100, 150, 10, doc.currentLineHeight(), file);
3636
// be aware that some PDF Viewers may not render the icon correctly — or not at all
3737
doc.fileAnnotation(150, 150, 10, doc.currentLineHeight(), file, {
3838
Name: 'Paperclip',
39-
Contents: 'Paperclip attachment'
39+
Contents: 'Paperclip attachment',
4040
});
4141

4242
doc.end();

examples/browserify/browser.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function makePDF(PDFDocument, blobStream, lorem, iframe) {
4949
[1, 1, 4, 4],
5050
3,
5151
3,
52-
'1 w 0 1 m 4 5 l s 2 0 m 5 3 l s'
52+
'1 w 0 1 m 4 5 l s 2 0 m 5 3 l s',
5353
);
5454
doc.circle(280, 350, 50).fill([stripe45d, 'blue']);
5555

@@ -72,12 +72,12 @@ function makePDF(PDFDocument, blobStream, lorem, iframe) {
7272
indent: 30,
7373
columns: 2,
7474
height: 300,
75-
ellipsis: true
75+
ellipsis: true,
7676
});
7777

7878
// end and display the document in the iframe to the right
7979
doc.end();
80-
stream.on('finish', function() {
80+
stream.on('finish', function () {
8181
iframe.src = stream.toBlobURL('application/pdf');
8282
});
8383
}
@@ -106,7 +106,7 @@ makePDF(PDFDocument, blobStream, lorem, iframe);
106106

107107
let debounceTimeout;
108108

109-
editor.getSession().on('change', function() {
109+
editor.getSession().on('change', function () {
110110
try {
111111
if (debounceTimeout) {
112112
clearTimeout(debounceTimeout);
@@ -116,7 +116,7 @@ editor.getSession().on('change', function() {
116116
'blobStream',
117117
'lorem',
118118
'iframe',
119-
editor.getValue()
119+
editor.getValue(),
120120
);
121121
debounceTimeout = setTimeout(() => {
122122
fn(PDFDocument, blobStream, lorem, iframe);

examples/form.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ doc.formText('leaf1', 10, y, 200, 20, {
2525
value: '1999-12-31',
2626
format: {
2727
type: 'date',
28-
param: 'yyyy-mm-dd'
28+
param: 'yyyy-mm-dd',
2929
},
30-
align: 'center'
30+
align: 'center',
3131
});
3232

3333
y += 30;
@@ -38,28 +38,28 @@ opts = {
3838
type: 'number',
3939
nDec: 2,
4040
currency: '$',
41-
currencyPrepend: true
41+
currencyPrepend: true,
4242
},
43-
align: 'right'
43+
align: 'right',
4444
};
4545
doc.formText('dollar', 10, y, 200, 20, opts);
4646

4747
y += 30;
4848
doc.formText('leaf2', 10, y, 200, 40, {
4949
parent: child1Field,
5050
multiline: true,
51-
align: 'right'
51+
align: 'right',
5252
});
5353
y += 50;
5454
doc.formText('leaf3', 10, y, 200, 80, {
5555
parent: child2Field,
56-
multiline: true
56+
multiline: true,
5757
});
5858

5959
y += 90;
6060
var opts = {
6161
backgroundColor: 'yellow',
62-
label: 'Test Button'
62+
label: 'Test Button',
6363
};
6464
doc.formPushButton('btn1', 10, y, 100, 30, opts);
6565

@@ -70,15 +70,15 @@ opts = {
7070
value: 'Select Option',
7171
defaultValue: 'Select Option',
7272
align: 'center',
73-
edit: true
73+
edit: true,
7474
};
7575
doc.formCombo('ch1', 10, y, 100, 20, opts);
7676

7777
y += 30;
7878
opts = {
7979
borderColor: '#808080',
8080
select: ['github', 'bitbucket', 'gitlab', 'sourcesafe', 'perforce'],
81-
sort: true
81+
sort: true,
8282
};
8383
doc.formList('ch2', 10, y, 100, 45, opts);
8484

0 commit comments

Comments
 (0)