diff --git a/core/lib/markdown_parser.js b/core/lib/markdown_parser.js index 960ae7638..9fd046a8f 100644 --- a/core/lib/markdown_parser.js +++ b/core/lib/markdown_parser.js @@ -25,7 +25,7 @@ var markdown_parser = function () { var frontmatterKey = frontmatterLineChunks[0].toLowerCase().trim(); var frontmatterValueString = frontmatterLineChunks[1].trim(); - returnObject[frontmatterKey] = frontmatterValueString.substring(1, frontmatterValueString.length - 1); + returnObject[frontmatterKey] = frontmatterValueString; } } diff --git a/test/files/_patterns/00-test/00-foo.md b/test/files/_patterns/00-test/00-foo.md new file mode 100644 index 000000000..4c8bbf296 --- /dev/null +++ b/test/files/_patterns/00-test/00-foo.md @@ -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. diff --git a/test/files/_patterns/00-test/01-bar.md b/test/files/_patterns/00-test/01-bar.md new file mode 100644 index 000000000..d4fd865a2 --- /dev/null +++ b/test/files/_patterns/00-test/01-bar.md @@ -0,0 +1,6 @@ +--- +status: complete +--- +## A Simple Bit of Markup + +Foo cannot get simpler than bar, amiright? diff --git a/test/files/annotations.md b/test/files/annotations.md index caea14bab..7e2ad972a 100644 --- a/test/files/annotations.md +++ b/test/files/annotations.md @@ -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. diff --git a/test/markdown_parser_tests.js b/test/markdown_parser_tests.js new file mode 100644 index 000000000..9a9998818 --- /dev/null +++ b/test/markdown_parser_tests.js @@ -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, '
This pattern contains an include of test-bar
. It also has this markdown file, which does not have frontmatter.
Foo cannot get simpler than bar, amiright?
\n'); + test.equals(returnObject.status, 'complete'); + test.done(); + } +}; diff --git a/test/style_modifier_hunter_tests.js b/test/style_modifier_hunter_tests.js index 7a3562ad0..4e0d7ddf3 100644 --- a/test/style_modifier_hunter_tests.js +++ b/test/style_modifier_hunter_tests.js @@ -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: '' - }; - - var style_modifier_hunter = new smh(); - - //act - style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl); - - //assert - test.equals(pattern.extendedTemplate, ''); - 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: '' - }; - - var style_modifier_hunter = new smh(); - - //act - style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl); - - //assert - test.equals(pattern.extendedTemplate, ''); - test.done(); - }, - 'replaces multiple style modifiers' : function(test){ - //arrange - var pl = {}; - pl.partials = {}; - pl.config = {}; - pl.config.debug = false; - - var pattern = { - extendedTemplate: '' - }; - - var style_modifier_hunter = new smh(); - - //act - style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar|baz|dum}}', pl); - - //assert - test.equals(pattern.extendedTemplate, ''); - 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: '' - }; - - var style_modifier_hunter = new smh(); - - //act - style_modifier_hunter.consume_style_modifier(pattern, '{{> partial}}', pl); - - //assert - test.equals(pattern.extendedTemplate, ''); - 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: '' + }; + + var style_modifier_hunter = new smh(); + + //act + style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl); + + //assert + test.equals(pattern.extendedTemplate, ''); + 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: '' + }; + + var style_modifier_hunter = new smh(); + + //act + style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar}}', pl); + + //assert + test.equals(pattern.extendedTemplate, ''); + test.done(); + }, + 'replaces multiple style modifiers' : function(test){ + //arrange + var pl = {}; + pl.partials = {}; + pl.config = {}; + pl.config.debug = false; + + var pattern = { + extendedTemplate: '' + }; + + var style_modifier_hunter = new smh(); + + //act + style_modifier_hunter.consume_style_modifier(pattern, '{{> partial:bar|baz|dum}}', pl); + + //assert + test.equals(pattern.extendedTemplate, ''); + 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: '' + }; + + var style_modifier_hunter = new smh(); + + //act + style_modifier_hunter.consume_style_modifier(pattern, '{{> partial}}', pl); + + //assert + test.equals(pattern.extendedTemplate, ''); + test.done(); + } +};