feat(aio): support unannotated JSON example files

This commit is contained in:
Peter Bacon Darwin 2017-02-22 18:12:34 +00:00 committed by Igor Minar
parent 1c08f1a6b2
commit 1282da1b14
2 changed files with 5 additions and 1 deletions

View File

@ -20,6 +20,7 @@ regionParserImpl.regionMatchers = {
css: blockC, css: blockC,
yaml: inlineHash, yaml: inlineHash,
jade: inlineCOnly, jade: inlineCOnly,
json: inlineC,
'json.annotated': inlineC 'json.annotated': inlineC
}; };
@ -97,6 +98,9 @@ function regionParserImpl(contents, fileType) {
// this line contained an annotation so let's filter it out // this line contained an annotation so let's filter it out
return false; return false;
}); });
if (!regionMap['']) {
regionMap[''] = {lines};
}
return { return {
contents: lines.join('\n'), contents: lines.join('\n'),
regions: mapObject(regionMap, (regionName, region) => region.lines.join('\n')) regions: mapObject(regionMap, (regionName, region) => region.lines.join('\n'))

View File

@ -25,7 +25,7 @@ describe('regionParser service', () => {
it('should return just the contents if there is a region-matcher but no regions', () => { it('should return just the contents if there is a region-matcher but no regions', () => {
const output = regionParser('some contents', 'test-type'); const output = regionParser('some contents', 'test-type');
expect(output).toEqual({contents: 'some contents', regions: {}}); expect(output).toEqual({contents: 'some contents', regions: { '': 'some contents' }});
}); });
it('should remove start region annotations from the contents', () => { it('should remove start region annotations from the contents', () => {