diff --git a/lib/generate.js b/lib/generate.js index a4e0119..e36c8f9 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -132,7 +132,7 @@ function generateLayoutInternal(options, callback) { if ( options.extractMetadata && options.format && - (img.svg.includes('mapbox-stretch') || img.svg.includes('mapbox-text-placeholder')) + (img.svg.includes('mapbox-stretch') || img.svg.includes('mapbox-text-placeholder') || img.svg.includes('mapbox-content')) ) { const metaOps = { svg: img.svg, pixelRatio: options.pixelRatio }; extractMetadata(metaOps, (err, metadataProps) => { diff --git a/test/fixture/svg-metadata/au-national-route-5-only-content.svg b/test/fixture/svg-metadata/au-national-route-5-only-content.svg new file mode 100644 index 0000000..c8062ea --- /dev/null +++ b/test/fixture/svg-metadata/au-national-route-5-only-content.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/test/generate.test.js b/test/generate.test.js index 67082b0..6461cdb 100644 --- a/test/generate.test.js +++ b/test/generate.test.js @@ -373,3 +373,29 @@ test('generateLayout with both placeholder and stretch zone', function (t) { t.end(); }); }); + +test('generateLayout with only content', function (t) { + var fixtures = [ + { + id: 'au-national-route-5-only-content', + svg: fs.readFileSync('./test/fixture/svg-metadata/au-national-route-5-only-content.svg') + } + ]; + spritezero.generateLayout({ imgs: fixtures, pixelRatio: 1, format: true }, function (err, formatted) { + t.ifError(err); + t.deepEqual( + formatted, + { + 'au-national-route-5-only-content': { + width: 38, + height: 20, + x: 0, + y: 0, + pixelRatio: 1, + content: [3, 7, 23, 18], + } + } + ); + t.end(); + }); +});