Skip to content

Commit 1a7d6d1

Browse files
committed
fix error with markdown parsing of pattern .md which might not have frontmatter
1 parent 781e2d5 commit 1a7d6d1

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

core/lib/markdown_parser.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var markdown_parser = function () {
1111
//for each block process the yaml frontmatter and markdown
1212
var frontmatterRE = /---\r?\n{1}([\s\S]*)---\r?\n{1}([\s\S]*)+/gm;
1313
var chunks = frontmatterRE.exec(block);
14-
if (chunks && chunks[1] && chunks[2]) {
14+
if (chunks && chunks[1]) {
1515

1616
//convert each yaml frontmatter key / value into an object key
1717
var frontmatter = chunks[1];
@@ -29,13 +29,19 @@ var markdown_parser = function () {
2929
}
3030

3131
}
32+
}
3233

34+
if (chunks && chunks[2]) {
3335
//parse the actual markdown
3436
returnObject.markdown = md.render(chunks[2]);
37+
} else{
38+
//assume the passed in block is raw markdown
39+
returnObject.markdown = md.render(block);
3540
}
3641
} catch (ex) {
3742
console.log(ex);
3843
console.log('error parsing markdown block', block);
44+
return undefined;
3945
}
4046

4147
//return the frontmatter keys and markdown for a consumer to decide what to do with

core/lib/pattern_assembler.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,12 @@ var pattern_assembler = function () {
174174
console.log('found pattern-specific markdown for ' + currentPattern.patternPartial);
175175
}
176176
}
177-
catch (e) {
178-
// do nothing
177+
catch (err) {
178+
// do nothing when file not found
179+
if (err.errno !== -4058) {
180+
console.log('there was an error setting pattern keys after markdown parsing of the companion file for pattern ' + currentPattern.patternPartial);
181+
console.log(err);
182+
}
179183
}
180184
}
181185

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "patternlab-node",
33
"description": "Pattern Lab is a collection of tools to help you create atomic design systems. This is the node command line interface (CLI).",
4-
"version": "2.1.0",
4+
"version": "2.1.1",
55
"main": "./core/lib/patternlab.js",
66
"dependencies": {
77
"diveSync": "^0.3.0",

0 commit comments

Comments
 (0)