From 553b5b1df802acbe2d62c130952bcb4f330a357c Mon Sep 17 00:00:00 2001 From: Jeff Parsons Date: Mon, 7 Dec 2015 13:19:08 -0800 Subject: [PATCH] Test removal of Front Matter from Markdown files --- docs/about/README.md | 6 ++++++ modules/markout/lib/markout.js | 11 +++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/about/README.md b/docs/about/README.md index c2d7ba4a7..3829ce295 100644 --- a/docs/about/README.md +++ b/docs/about/README.md @@ -1,3 +1,9 @@ +--- +layout: page +title: About JavaScript Machines +permalink: /docs/about/ +--- + About JavaScript Machines --- diff --git a/modules/markout/lib/markout.js b/modules/markout/lib/markout.js index c85daab65..bb3adb3b5 100644 --- a/modules/markout/lib/markout.js +++ b/modules/markout/lib/markout.js @@ -341,11 +341,18 @@ MarkOut.prototype.convertMD = function(sIndent) * * $sMD = preg_replace("%%s", "", $sMD); * - * NOTE: I found the following trick online: use "[\s\S]" to match any character, to work around JavaScript's - * lack of support for the "s" (aka "dotall" or "multiline") option that changes "." to match newlines. + * NOTE: I found the following trick online: use "[\s\S]" to match any character and work around + * the lack of JavaScript support for the "s" (aka "dotall" or "multiline") option that enables + * "." to match newlines. */ sMD = sMD.replace(//g, ""); + /* + * If the Markdown begins with a triple-dash, we assume there's a "Front Matter" header at the + * top of the file that we don't want to output, either. + */ + sMD = sMD.replace(/^---[\s\S]*?---[ \t]*\n*/, ""); + /* * Convert all lone series of three or more hyphens/underscores/asterisks into horizontal rules. */