Skip to content

Commit cd54e1f

Browse files
authored
Merge pull request #46 from sqrrrl/master
Bump version
2 parents 641cbfd + 93c0f4a commit cd54e1f

File tree

7 files changed

+37
-27
lines changed

7 files changed

+37
-27
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Changelog
22

3-
## (pending)
3+
## 0.5
44

5+
* Change handling of STDIN from command line. File arg is now optional, reads from stdin when omitted
56
* Support local image upload (via file.io) and rasterization of SVG and TeX/MathML expressions
67
* Fix image alignment when included in a column
78
* Allow offsets for images

bin/md2gslides.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ var parser = new ArgumentParser({
3939
});
4040

4141
parser.addArgument('file', {
42-
help: 'Path to markdown file to convert',
43-
required: false,
42+
help: 'Path to markdown file to convert, If omitted, reads from stdin',
43+
nargs: '?',
4444
});
4545
parser.addArgument(['-u', '--user'], {
4646
help: 'Email address of user',
4747
required: false,
48+
dest: 'user',
4849
defaultValue: 'default',
4950
});
5051
parser.addArgument(['-a', '--append'], {
@@ -164,12 +165,15 @@ function loadCss(theme) {
164165
}
165166

166167
function generateSlides(slideGenerator) {
167-
const file = args.file == 'STDIN' ? 0 : path.resolve(args.file);
168-
if (file != 0) {
168+
let source;
169+
if (args.file) {
170+
source = path.resolve(args.file);
169171
// Set working directory relative to markdown file
170-
process.chdir(path.dirname(file));
172+
process.chdir(path.dirname(source));
173+
} else {
174+
source = 0;
171175
}
172-
const input = fs.readFileSync(file, { encoding: 'UTF-8' });
176+
const input = fs.readFileSync(source, { encoding: 'UTF-8' });
173177
const css = loadCss(args.style);
174178

175179
return slideGenerator.generateFromMarkdown(input, {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "md2gslides",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"description": "Convert Markdown to Google Slides",
55
"main": "index.js",
66
"files": [

src/parser/extract_slides.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ inlineTokenRules['html_inline'] = (token, context) => {
140140
// Depending on spacing, comment blocks
141141
// sometimes appear as inline elements
142142
fullTokenRules['html_block'](token, context);
143-
return
143+
return;
144144
default:
145145
throw new Error('Unsupported inline HTML element: ' + node.nodeName);
146146
}

test/extract_slides.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ describe('extractSlides', function() {
115115
const slides = extractSlides(markdown);
116116

117117
it('should have a background image', function() {
118-
return expect(slides).to.have.nested.property('[0].bodies[0].images[0].url', 'https://example.com/image.jpg');
118+
return expect(slides).to.have.nested.property(
119+
'[0].bodies[0].images[0].url',
120+
'https://example.com/image.jpg',
121+
);
119122
});
120123

121124
it('should have an image x offset', function() {
@@ -366,7 +369,10 @@ describe('extractSlides', function() {
366369
});
367370

368371
it('should have the correct style', function() {
369-
return expect(slides).to.have.nested.property('[0].bodies[0].text.textRuns[0].baselineOffset', 'SUPERSCRIPT');
372+
return expect(slides).to.have.nested.property(
373+
'[0].bodies[0].text.textRuns[0].baselineOffset',
374+
'SUPERSCRIPT',
375+
);
370376
});
371377
});
372378

test/generic_layout.spec.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe('GenericLayout', function() {
110110
textRuns: [],
111111
listMarkers: [],
112112
big: false,
113-
},
113+
},
114114
},
115115
],
116116
tables: [],
@@ -156,15 +156,15 @@ describe('GenericLayout', function() {
156156
rawText: 'This is the left column\n',
157157
textRuns: [],
158158
listMarkers: [],
159-
}
159+
},
160160
},
161161
{
162162
text: {
163163
big: false,
164164
rawText: 'This is the right column\n',
165165
textRuns: [],
166166
listMarkers: [],
167-
}
167+
},
168168
},
169169
],
170170
tables: [],
@@ -214,7 +214,7 @@ describe('GenericLayout', function() {
214214
rawText: '\n',
215215
textRuns: [],
216216
listMarkers: [],
217-
}
217+
},
218218
},
219219
],
220220
tables: [],
@@ -259,9 +259,9 @@ describe('GenericLayout', function() {
259259
width: 350,
260260
height: 315,
261261
},
262-
],
263-
}
264-
]
262+
],
263+
},
264+
],
265265
};
266266
const layout = new GenericLayout('', presentation, input);
267267
layout.appendContentRequests(requests);
@@ -301,10 +301,9 @@ describe('GenericLayout', function() {
301301
},
302302
],
303303
images: [],
304-
}
304+
},
305305
],
306306
tables: [],
307-
308307
};
309308
const layout = new GenericLayout('', presentation, input);
310309
layout.appendContentRequests(requests);
@@ -497,7 +496,7 @@ describe('GenericLayout', function() {
497496
},
498497
],
499498
},
500-
}
499+
},
501500
],
502501
tables: [],
503502
};

test/match_layout.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('matchLayout', function() {
6161
{
6262
title: { rawText: 'title' },
6363
subtitle: { rawText: 'subtitle' },
64-
bodies: [{ text: {rawText: 'body' }}],
64+
bodies: [{ text: { rawText: 'body' } }],
6565
tables: [],
6666
},
6767
],
@@ -70,7 +70,7 @@ describe('matchLayout', function() {
7070
{
7171
title: { rawText: 'title', big: true },
7272
subtitle: null,
73-
bodies: [{ text: {rawText: 'body' }}],
73+
bodies: [{ text: { rawText: 'body' } }],
7474
tables: [],
7575
},
7676
],
@@ -79,7 +79,7 @@ describe('matchLayout', function() {
7979
{
8080
title: { rawText: 'title' },
8181
subtitle: null,
82-
bodies: [{ text: { rawText: 'column1' }}, { text: { rawText: 'column2' }}],
82+
bodies: [{ text: { rawText: 'column1' } }, { text: { rawText: 'column2' } }],
8383
tables: [],
8484
},
8585
],
@@ -88,7 +88,7 @@ describe('matchLayout', function() {
8888
{
8989
title: { rawText: 'title' },
9090
subtitle: null,
91-
bodies: [{ text: { rawText: 'body' }}],
91+
bodies: [{ text: { rawText: 'body' } }],
9292
tables: [],
9393
images: [],
9494
videos: [],
@@ -99,7 +99,7 @@ describe('matchLayout', function() {
9999
{
100100
title: { rawText: 'title' },
101101
subtitle: null,
102-
bodies: [{ images: [{ url: 'https://source.unsplash.com/78A265wPiO4/1600x900', padding: 0 }]}],
102+
bodies: [{ images: [{ url: 'https://source.unsplash.com/78A265wPiO4/1600x900', padding: 0 }] }],
103103
tables: [],
104104
},
105105
],
@@ -117,7 +117,7 @@ describe('matchLayout', function() {
117117
{
118118
title: null,
119119
subtitle: null,
120-
bodies: [{ images: [{ url: 'https://source.unsplash.com/78A265wPiO4/1600x900', padding: 0 }]}],
120+
bodies: [{ images: [{ url: 'https://source.unsplash.com/78A265wPiO4/1600x900', padding: 0 }] }],
121121
tables: [],
122122
videos: [],
123123
},

0 commit comments

Comments
 (0)