Skip to content

Commit

Permalink
Merge pull request #46 from sqrrrl/master
Browse files Browse the repository at this point in the history
Bump version
  • Loading branch information
sqrrrl authored Apr 6, 2019
2 parents 641cbfd + 93c0f4a commit cd54e1f
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 27 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## (pending)
## 0.5

* Change handling of STDIN from command line. File arg is now optional, reads from stdin when omitted
* Support local image upload (via file.io) and rasterization of SVG and TeX/MathML expressions
* Fix image alignment when included in a column
* Allow offsets for images
Expand Down
16 changes: 10 additions & 6 deletions bin/md2gslides.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ var parser = new ArgumentParser({
});

parser.addArgument('file', {
help: 'Path to markdown file to convert',
required: false,
help: 'Path to markdown file to convert, If omitted, reads from stdin',
nargs: '?',
});
parser.addArgument(['-u', '--user'], {
help: 'Email address of user',
required: false,
dest: 'user',
defaultValue: 'default',
});
parser.addArgument(['-a', '--append'], {
Expand Down Expand Up @@ -164,12 +165,15 @@ function loadCss(theme) {
}

function generateSlides(slideGenerator) {
const file = args.file == 'STDIN' ? 0 : path.resolve(args.file);
if (file != 0) {
let source;
if (args.file) {
source = path.resolve(args.file);
// Set working directory relative to markdown file
process.chdir(path.dirname(file));
process.chdir(path.dirname(source));
} else {
source = 0;
}
const input = fs.readFileSync(file, { encoding: 'UTF-8' });
const input = fs.readFileSync(source, { encoding: 'UTF-8' });
const css = loadCss(args.style);

return slideGenerator.generateFromMarkdown(input, {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "md2gslides",
"version": "0.4.0",
"version": "0.5.0",
"description": "Convert Markdown to Google Slides",
"main": "index.js",
"files": [
Expand Down
2 changes: 1 addition & 1 deletion src/parser/extract_slides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ inlineTokenRules['html_inline'] = (token, context) => {
// Depending on spacing, comment blocks
// sometimes appear as inline elements
fullTokenRules['html_block'](token, context);
return
return;
default:
throw new Error('Unsupported inline HTML element: ' + node.nodeName);
}
Expand Down
10 changes: 8 additions & 2 deletions test/extract_slides.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ describe('extractSlides', function() {
const slides = extractSlides(markdown);

it('should have a background image', function() {
return expect(slides).to.have.nested.property('[0].bodies[0].images[0].url', 'https://example.com/image.jpg');
return expect(slides).to.have.nested.property(
'[0].bodies[0].images[0].url',
'https://example.com/image.jpg',
);
});

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

it('should have the correct style', function() {
return expect(slides).to.have.nested.property('[0].bodies[0].text.textRuns[0].baselineOffset', 'SUPERSCRIPT');
return expect(slides).to.have.nested.property(
'[0].bodies[0].text.textRuns[0].baselineOffset',
'SUPERSCRIPT',
);
});
});

Expand Down
19 changes: 9 additions & 10 deletions test/generic_layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ describe('GenericLayout', function() {
textRuns: [],
listMarkers: [],
big: false,
},
},
},
],
tables: [],
Expand Down Expand Up @@ -156,15 +156,15 @@ describe('GenericLayout', function() {
rawText: 'This is the left column\n',
textRuns: [],
listMarkers: [],
}
},
},
{
text: {
big: false,
rawText: 'This is the right column\n',
textRuns: [],
listMarkers: [],
}
},
},
],
tables: [],
Expand Down Expand Up @@ -214,7 +214,7 @@ describe('GenericLayout', function() {
rawText: '\n',
textRuns: [],
listMarkers: [],
}
},
},
],
tables: [],
Expand Down Expand Up @@ -259,9 +259,9 @@ describe('GenericLayout', function() {
width: 350,
height: 315,
},
],
}
]
],
},
],
};
const layout = new GenericLayout('', presentation, input);
layout.appendContentRequests(requests);
Expand Down Expand Up @@ -301,10 +301,9 @@ describe('GenericLayout', function() {
},
],
images: [],
}
},
],
tables: [],

};
const layout = new GenericLayout('', presentation, input);
layout.appendContentRequests(requests);
Expand Down Expand Up @@ -497,7 +496,7 @@ describe('GenericLayout', function() {
},
],
},
}
},
],
tables: [],
};
Expand Down
12 changes: 6 additions & 6 deletions test/match_layout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('matchLayout', function() {
{
title: { rawText: 'title' },
subtitle: { rawText: 'subtitle' },
bodies: [{ text: {rawText: 'body' }}],
bodies: [{ text: { rawText: 'body' } }],
tables: [],
},
],
Expand All @@ -70,7 +70,7 @@ describe('matchLayout', function() {
{
title: { rawText: 'title', big: true },
subtitle: null,
bodies: [{ text: {rawText: 'body' }}],
bodies: [{ text: { rawText: 'body' } }],
tables: [],
},
],
Expand All @@ -79,7 +79,7 @@ describe('matchLayout', function() {
{
title: { rawText: 'title' },
subtitle: null,
bodies: [{ text: { rawText: 'column1' }}, { text: { rawText: 'column2' }}],
bodies: [{ text: { rawText: 'column1' } }, { text: { rawText: 'column2' } }],
tables: [],
},
],
Expand All @@ -88,7 +88,7 @@ describe('matchLayout', function() {
{
title: { rawText: 'title' },
subtitle: null,
bodies: [{ text: { rawText: 'body' }}],
bodies: [{ text: { rawText: 'body' } }],
tables: [],
images: [],
videos: [],
Expand All @@ -99,7 +99,7 @@ describe('matchLayout', function() {
{
title: { rawText: 'title' },
subtitle: null,
bodies: [{ images: [{ url: 'https://source.unsplash.com/78A265wPiO4/1600x900', padding: 0 }]}],
bodies: [{ images: [{ url: 'https://source.unsplash.com/78A265wPiO4/1600x900', padding: 0 }] }],
tables: [],
},
],
Expand All @@ -117,7 +117,7 @@ describe('matchLayout', function() {
{
title: null,
subtitle: null,
bodies: [{ images: [{ url: 'https://source.unsplash.com/78A265wPiO4/1600x900', padding: 0 }]}],
bodies: [{ images: [{ url: 'https://source.unsplash.com/78A265wPiO4/1600x900', padding: 0 }] }],
tables: [],
videos: [],
},
Expand Down

0 comments on commit cd54e1f

Please sign in to comment.