-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #382 from pattern-lab/markdown-parse-error
Parse markdown frontmatter better
- Loading branch information
Showing
8 changed files
with
151 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## A Simple Include | ||
|
||
This pattern contains an include of `test-bar`. It also has this markdown file, which does not have frontmatter. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
status: complete | ||
--- | ||
## A Simple Bit of Markup | ||
|
||
Foo cannot get simpler than bar, amiright? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
--- | ||
el: "header[role=banner]" | ||
title: "Masthead" | ||
el: header[role=banner] | ||
title: Masthead | ||
--- | ||
The main header of the site doesn't take up *too much screen real estate* in order to keep the focus on the core content. | ||
It's using a linear CSS gradient instead of a background image to give greater design flexibility and reduce HTTP requests. | ||
~*~ | ||
--- | ||
selector: ".logo" | ||
title: "Logo" | ||
selector: .logo | ||
title: Logo | ||
--- | ||
The _logo image_ is an SVG file. | ||
~*~ | ||
--- | ||
el: "#nav" | ||
title : "Navigation" | ||
el: #nav | ||
title : Navigation | ||
--- | ||
Navigation for adaptive web experiences can be tricky. Refer to [these repsonsive patterns](https://bradfrost.github.io/this-is-responsive/patterns.html#navigation) when evaluating solutions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
var path = require('path'); | ||
var fs = require('fs-extra'); | ||
var eol = require('os').EOL; | ||
var mp = require('../core/lib/markdown_parser'); | ||
var markdown_parser = new mp(); | ||
|
||
exports['markdown_parser'] = { | ||
'parses pattern description block correctly when frontmatter not present' : function(test){ | ||
//arrange | ||
var markdownFileName = path.resolve("./test/files/_patterns/00-test/00-foo.md"); | ||
var markdownFileContents = fs.readFileSync(markdownFileName, 'utf8'); | ||
|
||
//act | ||
var returnObject = markdown_parser.parse(markdownFileContents) | ||
|
||
//assert | ||
test.equals(returnObject.markdown, '<h2>A Simple Include</h2>\n<p>This pattern contains an include of <code>test-bar</code>. It also has this markdown file, which does not have frontmatter.</p>\n'); | ||
test.done(); | ||
}, | ||
'parses pattern description block correctly when frontmatter present' : function(test){ | ||
//arrange | ||
var markdownFileName = path.resolve("./test/files/_patterns/00-test/01-bar.md"); | ||
var markdownFileContents = fs.readFileSync(markdownFileName, 'utf8'); | ||
|
||
//act | ||
var returnObject = markdown_parser.parse(markdownFileContents) | ||
|
||
//assert | ||
test.equals(returnObject.markdown, '<h2>A Simple Bit of Markup</h2>\n<p>Foo cannot get simpler than bar, amiright?</p>\n'); | ||
test.equals(returnObject.status, 'complete'); | ||
test.done(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,89 +1,86 @@ | ||
(function () { | ||
"use strict"; | ||
|
||
var smh = require('../core/lib/style_modifier_hunter'); | ||
|
||
exports['consume_style_modifier'] = { | ||
'uses the partial stylemodifer to modify the patterns extendedTemplate' : function(test){ | ||
//arrange | ||
var pl = {}; | ||
pl.partials = {}; | ||
pl.config = {}; | ||
pl.config.debug = false; | ||
|
||
var pattern = { | ||
extendedTemplate: '<div class="foo {{styleModifier}}"></div>' | ||
}; | ||
|
||
var style_modifier_hunter = new smh(); | ||
|
||
//act | ||
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl); | ||
|
||
//assert | ||
test.equals(pattern.extendedTemplate, '<div class="foo bar"></div>'); | ||
test.done(); | ||
}, | ||
'replaces style modifiers with spaces in the syntax' : function(test){ | ||
//arrange | ||
var pl = {}; | ||
pl.partials = {}; | ||
pl.config = {}; | ||
pl.config.debug = false; | ||
|
||
var pattern = { | ||
extendedTemplate: '<div class="foo {{ styleModifier }}"></div>' | ||
}; | ||
|
||
var style_modifier_hunter = new smh(); | ||
|
||
//act | ||
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl); | ||
|
||
//assert | ||
test.equals(pattern.extendedTemplate, '<div class="foo bar"></div>'); | ||
test.done(); | ||
}, | ||
'replaces multiple style modifiers' : function(test){ | ||
//arrange | ||
var pl = {}; | ||
pl.partials = {}; | ||
pl.config = {}; | ||
pl.config.debug = false; | ||
|
||
var pattern = { | ||
extendedTemplate: '<div class="foo {{ styleModifier }}"></div>' | ||
}; | ||
|
||
var style_modifier_hunter = new smh(); | ||
|
||
//act | ||
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar|baz|dum}}', pl); | ||
|
||
//assert | ||
test.equals(pattern.extendedTemplate, '<div class="foo bar baz dum"></div>'); | ||
test.done(); | ||
}, | ||
'does not alter pattern extendedTemplate if styleModifier not found in partial' : function(test){ | ||
//arrange | ||
var pl = {}; | ||
pl.partials = {}; | ||
pl.config = {}; | ||
pl.config.debug = false; | ||
|
||
var pattern = { | ||
extendedTemplate: '<div class="foo {{styleModifier}}"></div>' | ||
}; | ||
|
||
var style_modifier_hunter = new smh(); | ||
|
||
//act | ||
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial}}', pl); | ||
|
||
//assert | ||
test.equals(pattern.extendedTemplate, '<div class="foo {{styleModifier}}"></div>'); | ||
test.done(); | ||
} | ||
}; | ||
|
||
}()); | ||
"use strict"; | ||
|
||
var smh = require('../core/lib/style_modifier_hunter'); | ||
|
||
exports['consume_style_modifier'] = { | ||
'uses the partial stylemodifer to modify the patterns extendedTemplate' : function(test){ | ||
//arrange | ||
var pl = {}; | ||
pl.partials = {}; | ||
pl.config = {}; | ||
pl.config.debug = false; | ||
|
||
var pattern = { | ||
extendedTemplate: '<div class="foo {{styleModifier}}"></div>' | ||
}; | ||
|
||
var style_modifier_hunter = new smh(); | ||
|
||
//act | ||
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl); | ||
|
||
//assert | ||
test.equals(pattern.extendedTemplate, '<div class="foo bar"></div>'); | ||
test.done(); | ||
}, | ||
'replaces style modifiers with spaces in the syntax' : function(test){ | ||
//arrange | ||
var pl = {}; | ||
pl.partials = {}; | ||
pl.config = {}; | ||
pl.config.debug = false; | ||
|
||
var pattern = { | ||
extendedTemplate: '<div class="foo {{ styleModifier }}"></div>' | ||
}; | ||
|
||
var style_modifier_hunter = new smh(); | ||
|
||
//act | ||
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl); | ||
|
||
//assert | ||
test.equals(pattern.extendedTemplate, '<div class="foo bar"></div>'); | ||
test.done(); | ||
}, | ||
'replaces multiple style modifiers' : function(test){ | ||
//arrange | ||
var pl = {}; | ||
pl.partials = {}; | ||
pl.config = {}; | ||
pl.config.debug = false; | ||
|
||
var pattern = { | ||
extendedTemplate: '<div class="foo {{ styleModifier }}"></div>' | ||
}; | ||
|
||
var style_modifier_hunter = new smh(); | ||
|
||
//act | ||
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar|baz|dum}}', pl); | ||
|
||
//assert | ||
test.equals(pattern.extendedTemplate, '<div class="foo bar baz dum"></div>'); | ||
test.done(); | ||
}, | ||
'does not alter pattern extendedTemplate if styleModifier not found in partial' : function(test){ | ||
//arrange | ||
var pl = {}; | ||
pl.partials = {}; | ||
pl.config = {}; | ||
pl.config.debug = false; | ||
|
||
var pattern = { | ||
extendedTemplate: '<div class="foo {{styleModifier}}"></div>' | ||
}; | ||
|
||
var style_modifier_hunter = new smh(); | ||
|
||
//act | ||
style_modifier_hunter.consume_style_modifier(pattern, '{{> partial}}', pl); | ||
|
||
//assert | ||
test.equals(pattern.extendedTemplate, '<div class="foo {{styleModifier}}"></div>'); | ||
test.done(); | ||
} | ||
}; |