|
1 | 1 | "use strict";
|
2 | 2 |
|
3 | 3 | var path = require('path'),
|
| 4 | + readDir = require('readdir'), |
4 | 5 | fs = require('fs-extra'),
|
5 | 6 | JSON5 = require('json5'),
|
6 | 7 | _ = require('lodash'),
|
@@ -42,32 +43,35 @@ var annotations_exporter = function (pl) {
|
42 | 43 | function parseAnnotationsMD() {
|
43 | 44 | var markdown_parser = new mp();
|
44 | 45 | var annotations = [];
|
45 |
| - |
46 |
| - //attempt to read the file |
47 |
| - var annotationsMD = ''; |
48 |
| - try { |
49 |
| - annotationsMD = fs.readFileSync(path.resolve(paths.source.annotations, 'annotations.md'), 'utf8'); |
50 |
| - } catch (ex) { |
51 |
| - if (pl.config.debug) { |
52 |
| - console.log('annotations.md file missing from ' + paths.source.annotations + '. This may be expected.'); |
| 46 | + var mdFiles = readDir.readSync(paths.source.annotations, ['*.md']) |
| 47 | + |
| 48 | + mdFiles.forEach(function (file) { |
| 49 | + var annotationsMD = ''; |
| 50 | + try { |
| 51 | + annotationsMD = fs.readFileSync(path.resolve(paths.source.annotations, file), 'utf8'); |
| 52 | + } catch (ex) { |
| 53 | + if (pl.config.debug) { |
| 54 | + console.log('annotations.md file missing from ' + paths.source.annotations + '. This may be expected.'); |
| 55 | + } |
| 56 | + return []; |
53 | 57 | }
|
54 |
| - return []; |
55 |
| - } |
56 | 58 |
|
57 | 59 | //take the annotation snippets and split them on our custom delimiter
|
58 |
| - var annotationsYAML = annotationsMD.split('~*~'); |
| 60 | + var annotationsYAML = annotationsMD.split('~*~'); |
59 | 61 |
|
60 |
| - for (var i = 0; i < annotationsYAML.length; i++) { |
61 |
| - var annotation = {}; |
| 62 | + for (var i = 0; i < annotationsYAML.length; i++) { |
| 63 | + var annotation = {}; |
62 | 64 |
|
63 |
| - var markdownObj = markdown_parser.parse(annotationsYAML[i]); |
| 65 | + var markdownObj = markdown_parser.parse(annotationsYAML[i]); |
64 | 66 |
|
65 |
| - annotation.el = markdownObj.el || markdownObj.selector; |
66 |
| - annotation.title = markdownObj.title; |
67 |
| - annotation.comment = markdownObj.markdown; |
| 67 | + annotation.el = markdownObj.el || markdownObj.selector; |
| 68 | + annotation.title = markdownObj.title; |
| 69 | + annotation.comment = markdownObj.markdown; |
68 | 70 |
|
69 |
| - annotations.push(annotation); |
70 |
| - } |
| 71 | + annotations.push(annotation); |
| 72 | + } |
| 73 | + return false; |
| 74 | + }) |
71 | 75 | return annotations;
|
72 | 76 | }
|
73 | 77 |
|
|
0 commit comments