Skip to content

Commit

Permalink
Format with npm run prettier -- --write
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Jan 28, 2025
1 parent 850d72b commit 6f371a8
Show file tree
Hide file tree
Showing 83 changed files with 1,755 additions and 3,356 deletions.
40 changes: 20 additions & 20 deletions docs/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,52 @@ const styles = {
h1: {
font: 'fonts/Alegreya-Bold.ttf',
fontSize: 25,
padding: 15
padding: 15,
},
h2: {
font: 'fonts/Alegreya-Bold.ttf',
fontSize: 18,
padding: 10
padding: 10,
},
h3: {
font: 'fonts/Alegreya-Bold.ttf',
fontSize: 18,
padding: 10
padding: 10,
},
para: {
font: 'fonts/Merriweather-Regular.ttf',
fontSize: 10,
padding: 10
padding: 10,
},
code: {
font: 'fonts/SourceCodePro-Regular.ttf',
fontSize: 9
fontSize: 9,
},
code_block: {
padding: 10,
background: '#2c2c2c'
background: '#2c2c2c',
},
inlinecode: {
font: 'fonts/SourceCodePro-Bold.ttf',
fontSize: 10
fontSize: 10,
},
listitem: {
font: 'fonts/Merriweather-Regular.ttf',
fontSize: 10,
padding: 6
padding: 6,
},
link: {
font: 'fonts/Merriweather-Regular.ttf',
fontSize: 10,
color: 'blue',
underline: true
underline: true,
},
example: {
font: 'Helvetica',
fontSize: 9,
color: 'black',
padding: 10
}
padding: 10,
},
};

// syntax highlighting colors
Expand Down Expand Up @@ -89,7 +89,7 @@ const colors = {
quote: '#93a1a1',
link: '#93a1a1',
special: '#6c71c4',
default: '#002b36'
default: '#002b36',
};

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

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

// sets the styles on the document for this node
setStyle (doc) {
setStyle(doc) {
if (this.style.font) {
doc.font(this.style.font);
}
Expand All @@ -189,7 +189,7 @@ class Node {
}

// renders this node and its subnodes to the document
render (doc, continued) {
render(doc, continued) {
let y;
if (continued == null) {
continued = false;
Expand All @@ -210,7 +210,7 @@ class Node {
// run the example code with the document
vm.runInNewContext(this.code, {
doc,
lorem
lorem,
});

// restore points and styles
Expand Down Expand Up @@ -257,7 +257,7 @@ class Node {
} else {
fragment.render(
doc,
index < this.content.length - 1 && this.type !== 'bulletlist'
index < this.content.length - 1 && this.type !== 'bulletlist',
);
}

Expand Down Expand Up @@ -286,7 +286,7 @@ const render = (doc, filename) => {
};

// renders the title page of the guide
const renderTitlePage = doc => {
const renderTitlePage = (doc) => {
const title = 'PDFKit Guide';
const author = 'By Devon Govett';
const version = `Version ${require('../package.json').version}`;
Expand All @@ -301,13 +301,13 @@ const renderTitlePage = doc => {
doc.y -= 10;
doc.text(author, {
align: 'center',
indent: w - doc.widthOfString(author)
indent: w - doc.widthOfString(author),
});

doc.font(styles.para.font, 10);
doc.text(version, {
align: 'center',
indent: w - doc.widthOfString(version)
indent: w - doc.widthOfString(version),
});

doc.addPage();
Expand Down
18 changes: 9 additions & 9 deletions docs/generate_website.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ const files = [
'destinations.md',
'attachments.md',
'accessibility.md',
'you_made_it.md'
'you_made_it.md',
];

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

const getNodeName = function(node) {
const getNodeName = function (node) {
if (node.length === 3) {
return node[2];
}
Expand All @@ -48,7 +48,7 @@ const getNodeName = function(node) {
return words.join('');
};

const extractHeaders = function(tree) {
const extractHeaders = function (tree) {
const headers = [];

for (let index = 0; index < tree.length; index++) {
Expand All @@ -62,7 +62,7 @@ const extractHeaders = function(tree) {
node[1].id = hash;
headers.push({
hash,
title: name
title: name,
});
}
}
Expand All @@ -71,7 +71,7 @@ const extractHeaders = function(tree) {
};

let imageIndex = 0;
const generateImages = function(tree) {
const generateImages = function (tree) {
// find code blocks
const codeBlocks = [];
for (var node of tree) {
Expand Down Expand Up @@ -99,7 +99,7 @@ const generateImages = function(tree) {

vm.runInNewContext(code, {
doc,
lorem
lorem,
});

delete attrs.title;
Expand All @@ -118,7 +118,7 @@ const generateImages = function(tree) {
console.error(err);
}
fs.unlinkSync(`${f}.pdf`);
}
},
);
});

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

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

Expand Down
8 changes: 4 additions & 4 deletions docs/publish_website.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ ghpages.publish(
'docs/guide.pdf',
'examples/browserify/browser.html',
'examples/browserify/bundle.js',
'examples/kitchen-sink.pdf'
'examples/kitchen-sink.pdf',
],
add: true,
message
message,
},
function(err) {
function (err) {
if (err) {
console.error(err);
}
}
},
);
6 changes: 3 additions & 3 deletions examples/attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ doc.info['Title'] = 'Attachment Test';
doc.file(path.join(__dirname, 'images', 'test.png'), {
name: 'test.png',
type: 'image/png',
description: 'this is a test image'
description: 'this is a test image',
});

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

doc.end();
10 changes: 5 additions & 5 deletions examples/browserify/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function makePDF(PDFDocument, blobStream, lorem, iframe) {
[1, 1, 4, 4],
3,
3,
'1 w 0 1 m 4 5 l s 2 0 m 5 3 l s'
'1 w 0 1 m 4 5 l s 2 0 m 5 3 l s',
);
doc.circle(280, 350, 50).fill([stripe45d, 'blue']);

Expand All @@ -72,12 +72,12 @@ function makePDF(PDFDocument, blobStream, lorem, iframe) {
indent: 30,
columns: 2,
height: 300,
ellipsis: true
ellipsis: true,
});

// end and display the document in the iframe to the right
doc.end();
stream.on('finish', function() {
stream.on('finish', function () {
iframe.src = stream.toBlobURL('application/pdf');
});
}
Expand Down Expand Up @@ -106,7 +106,7 @@ makePDF(PDFDocument, blobStream, lorem, iframe);

let debounceTimeout;

editor.getSession().on('change', function() {
editor.getSession().on('change', function () {
try {
if (debounceTimeout) {
clearTimeout(debounceTimeout);
Expand All @@ -116,7 +116,7 @@ editor.getSession().on('change', function() {
'blobStream',
'lorem',
'iframe',
editor.getValue()
editor.getValue(),
);
debounceTimeout = setTimeout(() => {
fn(PDFDocument, blobStream, lorem, iframe);
Expand Down
18 changes: 9 additions & 9 deletions examples/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ doc.formText('leaf1', 10, y, 200, 20, {
value: '1999-12-31',
format: {
type: 'date',
param: 'yyyy-mm-dd'
param: 'yyyy-mm-dd',
},
align: 'center'
align: 'center',
});

y += 30;
Expand All @@ -38,28 +38,28 @@ opts = {
type: 'number',
nDec: 2,
currency: '$',
currencyPrepend: true
currencyPrepend: true,
},
align: 'right'
align: 'right',
};
doc.formText('dollar', 10, y, 200, 20, opts);

y += 30;
doc.formText('leaf2', 10, y, 200, 40, {
parent: child1Field,
multiline: true,
align: 'right'
align: 'right',
});
y += 50;
doc.formText('leaf3', 10, y, 200, 80, {
parent: child2Field,
multiline: true
multiline: true,
});

y += 90;
var opts = {
backgroundColor: 'yellow',
label: 'Test Button'
label: 'Test Button',
};
doc.formPushButton('btn1', 10, y, 100, 30, opts);

Expand All @@ -70,15 +70,15 @@ opts = {
value: 'Select Option',
defaultValue: 'Select Option',
align: 'center',
edit: true
edit: true,
};
doc.formCombo('ch1', 10, y, 100, 20, opts);

y += 30;
opts = {
borderColor: '#808080',
select: ['github', 'bitbucket', 'gitlab', 'sourcesafe', 'perforce'],
sort: true
sort: true,
};
doc.formList('ch2', 10, y, 100, 45, opts);

Expand Down
Loading

0 comments on commit 6f371a8

Please sign in to comment.