Skip to content

Commit a76ab28

Browse files
committed
Apply prettier formatting
1 parent 8b087ce commit a76ab28

Some content is hidden

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

65 files changed

+1565
-3195
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;
@@ -217,7 +217,7 @@ class Node {
217217
// run the example code with the document
218218
vm.runInNewContext(this.code, {
219219
doc,
220-
lorem
220+
lorem,
221221
});
222222

223223
// restore points and styles
@@ -273,7 +273,7 @@ class Node {
273273
} else {
274274
fragment.render(
275275
doc,
276-
index < this.content.length - 1 && this.type !== 'bulletlist'
276+
index < this.content.length - 1 && this.type !== 'bulletlist',
277277
);
278278
}
279279

@@ -302,7 +302,7 @@ const render = (doc, filename) => {
302302
};
303303

304304
// renders the title page of the guide
305-
const renderTitlePage = doc => {
305+
const renderTitlePage = (doc) => {
306306
const title = 'PDFKit Guide';
307307
const author = 'By Devon Govett';
308308
const version = `Version ${require('../package.json').version}`;
@@ -317,13 +317,13 @@ const renderTitlePage = doc => {
317317
doc.y -= 10;
318318
doc.text(author, {
319319
align: 'center',
320-
indent: w - doc.widthOfString(author)
320+
indent: w - doc.widthOfString(author),
321321
});
322322

323323
doc.font(styles.para.font, 10);
324324
doc.text(version, {
325325
align: 'center',
326-
indent: w - doc.widthOfString(version)
326+
indent: w - doc.widthOfString(version),
327327
});
328328

329329
doc.addPage();

docs/generate_website.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ const files = [
2525
'attachments.md',
2626
'accessibility.md',
2727
'table.md',
28-
'you_made_it.md'
28+
'you_made_it.md',
2929
];
3030

3131
// shared lorem ipsum text so we don't need to copy it into every example
3232
const lorem =
3333
'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;';
3434

35-
const getNodeName = function(node) {
35+
const getNodeName = function (node) {
3636
if (node.length === 3) {
3737
return node[2];
3838
}
@@ -49,7 +49,7 @@ const getNodeName = function(node) {
4949
return words.join('');
5050
};
5151

52-
const extractHeaders = function(tree) {
52+
const extractHeaders = function (tree) {
5353
const headers = [];
5454

5555
for (let index = 0; index < tree.length; index++) {
@@ -63,7 +63,7 @@ const extractHeaders = function(tree) {
6363
node[1].id = hash;
6464
headers.push({
6565
hash,
66-
title: name
66+
title: name,
6767
});
6868
}
6969
}
@@ -72,7 +72,7 @@ const extractHeaders = function(tree) {
7272
};
7373

7474
let imageIndex = 0;
75-
const generateImages = function(tree) {
75+
const generateImages = function (tree) {
7676
// find code blocks
7777
const codeBlocks = [];
7878
for (var node of tree) {
@@ -100,7 +100,7 @@ const generateImages = function(tree) {
100100

101101
vm.runInNewContext(code, {
102102
doc,
103-
lorem
103+
lorem,
104104
});
105105

106106
delete attrs.title;
@@ -119,7 +119,7 @@ const generateImages = function(tree) {
119119
console.error(err);
120120
}
121121
fs.unlinkSync(`${f}.pdf`);
122-
}
122+
},
123123
);
124124
});
125125

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

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

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
);

lib/data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ class Data {
187187
}
188188

189189
write(bytes) {
190-
return bytes.map(byte => this.writeByte(byte));
190+
return bytes.map((byte) => this.writeByte(byte));
191191
}
192192
}
193193

lib/font/afm.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const WIN_ANSI_MAP = {
2727
353: 154,
2828
376: 159,
2929
381: 142,
30-
382: 158
30+
382: 158,
3131
};
3232

3333
const characters = `\
@@ -123,7 +123,7 @@ class AFMFont {
123123
this.charWidths[char] = this.glyphWidths[characters[char]];
124124
}
125125

126-
this.bbox = this.attributes['FontBBox'].split(/\s+/).map(e => +e);
126+
this.bbox = this.attributes['FontBBox'].split(/\s+/).map((e) => +e);
127127
this.ascender = +(this.attributes['Ascender'] || 0);
128128
this.descender = +(this.attributes['Descender'] || 0);
129129
this.xHeight = +(this.attributes['XHeight'] || 0);

lib/font/embedded.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PDFFont from '../font';
22

3-
const toHex = function(num) {
3+
const toHex = function (num) {
44
return `0000${num.toString(16)}`.slice(-4);
55
};
66

@@ -151,7 +151,7 @@ class EmbeddedFont extends PDFFont {
151151

152152
// generate a tag (6 uppercase letters. 17 is the char code offset from '0' to 'A'. 73 will map to 'Z')
153153
const tag = [1, 2, 3, 4, 5, 6]
154-
.map(i => String.fromCharCode((this.id.charCodeAt(i) || 73) + 17))
154+
.map((i) => String.fromCharCode((this.id.charCodeAt(i) || 73) + 17))
155155
.join('');
156156
const name = tag + '+' + this.font.postscriptName?.replaceAll(' ', '_');
157157

@@ -164,14 +164,14 @@ class EmbeddedFont extends PDFFont {
164164
bbox.minX * this.scale,
165165
bbox.minY * this.scale,
166166
bbox.maxX * this.scale,
167-
bbox.maxY * this.scale
167+
bbox.maxY * this.scale,
168168
],
169169
ItalicAngle: this.font.italicAngle,
170170
Ascent: this.ascender,
171171
Descent: this.descender,
172172
CapHeight: (this.font.capHeight || this.font.ascent) * this.scale,
173173
XHeight: (this.font.xHeight || 0) * this.scale,
174-
StemV: 0
174+
StemV: 0,
175175
}); // not sure how to calculate this
176176

177177
if (isCFF) {
@@ -198,10 +198,10 @@ class EmbeddedFont extends PDFFont {
198198
CIDSystemInfo: {
199199
Registry: new String('Adobe'),
200200
Ordering: new String('Identity'),
201-
Supplement: 0
201+
Supplement: 0,
202202
},
203203
FontDescriptor: descriptor,
204-
W: [0, this.widths]
204+
W: [0, this.widths],
205205
};
206206

207207
if (!isCFF) {
@@ -219,7 +219,7 @@ class EmbeddedFont extends PDFFont {
219219
BaseFont: name,
220220
Encoding: 'Identity-H',
221221
DescendantFonts: [descendantFont],
222-
ToUnicode: this.toUnicodeCmap()
222+
ToUnicode: this.toUnicodeCmap(),
223223
};
224224

225225
return this.dictionary.end();
@@ -255,7 +255,9 @@ class EmbeddedFont extends PDFFont {
255255
for (let i = 0; i < chunks; i++) {
256256
const start = i * chunkSize;
257257
const end = Math.min((i + 1) * chunkSize, entries.length);
258-
ranges.push(`<${toHex(start)}> <${toHex(end - 1)}> [${entries.slice(start, end).join(' ')}]`);
258+
ranges.push(
259+
`<${toHex(start)}> <${toHex(end - 1)}> [${entries.slice(start, end).join(' ')}]`,
260+
);
259261
}
260262

261263
cmap.end(`\

lib/font/standard.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const STANDARD_FONTS = {
2828
'Helvetica-BoldOblique'() {
2929
return fs.readFileSync(
3030
__dirname + '/data/Helvetica-BoldOblique.afm',
31-
'utf8'
31+
'utf8',
3232
);
3333
},
3434
'Times-Roman'() {
@@ -48,7 +48,7 @@ const STANDARD_FONTS = {
4848
},
4949
ZapfDingbats() {
5050
return fs.readFileSync(__dirname + '/data/ZapfDingbats.afm', 'utf8');
51-
}
51+
},
5252
};
5353

5454
class StandardFont extends PDFFont {
@@ -64,7 +64,7 @@ class StandardFont extends PDFFont {
6464
bbox: this.bbox,
6565
lineGap: this.lineGap,
6666
xHeight: this.xHeight,
67-
capHeight: this.capHeight
67+
capHeight: this.capHeight,
6868
} = this.font);
6969
}
7070

@@ -73,7 +73,7 @@ class StandardFont extends PDFFont {
7373
Type: 'Font',
7474
BaseFont: this.name,
7575
Subtype: 'Type1',
76-
Encoding: 'WinAnsiEncoding'
76+
Encoding: 'WinAnsiEncoding',
7777
};
7878

7979
return this.dictionary.end();
@@ -91,7 +91,7 @@ class StandardFont extends PDFFont {
9191
yAdvance: 0,
9292
xOffset: 0,
9393
yOffset: 0,
94-
advanceWidth: this.font.widthOfGlyph(glyph)
94+
advanceWidth: this.font.widthOfGlyph(glyph),
9595
});
9696
}
9797

0 commit comments

Comments
 (0)