Commit 6e68c32a authored by Ken Hawkins's avatar Ken Hawkins
Browse files

Support for marked 4 and babel/core

parent 4cc40dd3
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
"@11ty/eleventy": "1.0.0-beta.8", "@11ty/eleventy": "1.0.0-beta.8",
"@visual-framework/vf-config": "1.0.1-alpha.0", "@visual-framework/vf-config": "1.0.1-alpha.0",
"@visual-framework/vf-core": "^2.2.33", "@visual-framework/vf-core": "^2.2.33",
"@visual-framework/vf-extensions": "^1.0.1", "@visual-framework/vf-core": "^2.2.36",
"@visual-framework/vf-extensions": "^2.0.0-alpha.1",
"html-minifier": "4.0.0", "html-minifier": "4.0.0",
"node-html-parser": "5.1.0", "node-html-parser": "5.1.0",
"require-dir": "1.2.0", "require-dir": "1.2.0",
......
### 2.2.36
* Use `renderMarkdown.parse` for marked 4+ support.
### 2.2.35
* Update @visual-framework/vf-frctl-extensions to ^2.0.0 for marked 4+ support.
### 2.2.34 ### 2.2.34
* Update marked to 4.0.4 * Update marked to 4.0.4
......
const renderMarkdown = require("marked");
module.exports = { module.exports = {
// mode: 'build' or 'server' // mode: 'build' or 'server'
initialize: function(mode, callback) { initialize: function(mode, callback) {
/* Create a new Fractal instance and export it for use elsewhere if required */ /* Create a new Fractal instance and export it for use elsewhere if required */
const fractal = module.exports = require('@frctl/fractal').create(); const fractal = module.exports = require("@frctl/fractal").create();
const logger = fractal.cli.console; const logger = fractal.cli.console;
var vfName = global.vfName || 'Visual Framework component library'; var vfName = global.vfName || "Visual Framework component library";
const projectTitle = vfName; const projectTitle = vfName;
const path = require('path'); const path = require("path");
/* Set the title of the project */ /* Set the title of the project */
fractal.set('project.title', projectTitle); fractal.set("project.title", projectTitle);
/* Tell Fractal where the components will live */ /* Tell Fractal where the components will live */
var vfComponentPath = global.vfComponentPath || __dirname + '/components'; var vfComponentPath = global.vfComponentPath || __dirname + "/components";
// Possible needed fix to resolve path // Possible needed fix to resolve path
// vfComponentPath = path.resolve('.',vfComponentPath); // vfComponentPath = path.resolve('.',vfComponentPath);
fractal.components.set('path', vfComponentPath); fractal.components.set("path", vfComponentPath);
/* Tell Fractal where the documentation pages will live */ /* Tell Fractal where the documentation pages will live */
var vfDocsPath = global.vfDocsPath || __dirname + '/docs'; var vfDocsPath = global.vfDocsPath || __dirname + "/docs";
fractal.docs.set('path', vfDocsPath); fractal.docs.set("path", vfDocsPath);
const nunj = require('@frctl/nunjucks')({ const nunj = require("@frctl/nunjucks")({
env: { env: {
lstripBlocks: true, lstripBlocks: true,
trimBlocks: true, trimBlocks: true,
...@@ -35,8 +37,7 @@ module.exports = { ...@@ -35,8 +37,7 @@ module.exports = {
filters: { filters: {
// {{ "## Parse me" | marked }} // {{ "## Parse me" | marked }}
marked: function(string) { marked: function(string) {
const renderMarkdown = require('marked'); return renderMarkdown.parse(string);
return renderMarkdown(string);
}, },
// A filter and non-async version of frctl's context extension from // A filter and non-async version of frctl's context extension from
// https://github.com/frctl/nunjucks/blob/develop/src/extensions/context.js // https://github.com/frctl/nunjucks/blob/develop/src/extensions/context.js
...@@ -55,61 +56,61 @@ module.exports = { ...@@ -55,61 +56,61 @@ module.exports = {
hextorgb: module.exports = function(text) { hextorgb: module.exports = function(text) {
function hexToRGB(hex) { function hexToRGB(hex) {
var r = parseInt(hex.slice(1, 3), 16), var r = parseInt(hex.slice(1, 3), 16),
g = parseInt(hex.slice(3, 5), 16), g = parseInt(hex.slice(3, 5), 16),
b = parseInt(hex.slice(5, 7), 16); b = parseInt(hex.slice(5, 7), 16);
return "rgb(" + r + ", " + g + ", " + b + ")"; return "rgb(" + r + ", " + g + ", " + b + ")";
} }
var hex = new String(text); var hex = new String(text);
return hexToRGB(hex); return hexToRGB(hex);
} }
}, },
// globals: { // globals: {
// // global-name: global-val // // global-name: global-val
// }, // },
extensions: { extensions: {
codeblock: require('@visual-framework/vf-frctl-extensions/codeblock.js')(fractal), codeblock: require("@visual-framework/vf-frctl-extensions/codeblock.js")(fractal),
spaceless: require('@visual-framework/vf-frctl-extensions/spaceless.js')(fractal), spaceless: require("@visual-framework/vf-frctl-extensions/spaceless.js")(fractal),
markdown: require('@visual-framework/vf-frctl-extensions/markdown.js')(fractal) markdown: require("@visual-framework/vf-frctl-extensions/markdown.js")(fractal)
} }
}); });
fractal.components.set('ext', '.njk'); // look for files with a .nunj file extension fractal.components.set("ext", ".njk"); // look for files with a .nunj file extension
fractal.components.engine(nunj); /* set as the default template engine for components */ fractal.components.engine(nunj); /* set as the default template engine for components */
fractal.docs.set('ext', '.njk'); // look for files with a .njk file extension fractal.docs.set("ext", ".njk"); // look for files with a .njk file extension
fractal.docs.engine(nunj); /* you can also use the same instance for documentation, if you like! */ fractal.docs.engine(nunj); /* you can also use the same instance for documentation, if you like! */
/* configure components */ /* configure components */
fractal.components.set('default.status', 'alpha'); fractal.components.set("default.status", "alpha");
fractal.components.set('default.preview', `@preview`); fractal.components.set("default.preview", "@preview");
/* build destination */ /* build destination */
var vfBuilderPath = global.vfBuilderPath || __dirname + '/build'; var vfBuilderPath = global.vfBuilderPath || __dirname + "/build";
fractal.web.set('builder.dest', vfBuilderPath); fractal.web.set("builder.dest", vfBuilderPath);
fractal.set('components.resources.assets.match', ['**/*.njk', '**/*.config.yml', '**/*.scss', '**/CHANGELOG.md', '**/*.js','**/*.css', '!**/*.precompiled.js', '!**/package.variables.scss', '!**/index.scss']) fractal.set("components.resources.assets.match", ["**/*.njk", "**/*.config.yml", "**/*.scss", "**/CHANGELOG.md", "**/*.js","**/*.css", "!**/*.precompiled.js", "!**/package.variables.scss", "!**/index.scss"]);
/* configure web */ /* configure web */
var vfStaticPath = global.vfStaticPath || __dirname + '/temp/build-files'; var vfStaticPath = global.vfStaticPath || __dirname + "/temp/build-files";
fractal.web.set('static.path', vfStaticPath); fractal.web.set("static.path", vfStaticPath);
fractal.web.set('server.sync', true); fractal.web.set("server.sync", true);
var vfOpenBrowser = typeof global.vfOpenBrowser === "undefined" ? true : global.vfOpenBrowser; var vfOpenBrowser = typeof global.vfOpenBrowser === "undefined" ? true : global.vfOpenBrowser;
fractal.web.set('server.syncOptions', { fractal.web.set("server.syncOptions", {
watchOptions: { watchOptions: {
// @todo: this should use vfComponentPath // @todo: this should use vfComponentPath
ignored: path.join(__dirname, '../../components/**/*.scss'), ignored: path.join(__dirname, "../../components/**/*.scss"),
}, },
open: vfOpenBrowser, open: vfOpenBrowser,
browser: 'default', browser: "default",
sync: true sync: true
}); });
var vfThemePath = global.vfThemePath || '@frctl/mandelbrot'; var vfThemePath = global.vfThemePath || "@frctl/mandelbrot";
const vfTheme = require(vfThemePath); const vfTheme = require(vfThemePath);
const vfThemeConfig = vfTheme({}, fractal); const vfThemeConfig = vfTheme({}, fractal);
fractal.components.set('statuses', { fractal.components.set("statuses", {
/* status definitions here */ /* status definitions here */
alpha: { alpha: {
label: "alpha", label: "alpha",
...@@ -136,8 +137,8 @@ module.exports = { ...@@ -136,8 +137,8 @@ module.exports = {
fractal.web.theme(vfThemeConfig); fractal.web.theme(vfThemeConfig);
if (mode == 'server') { if (mode == "server") {
fractal.set('project.environment.local', 'true'); fractal.set("project.environment.local", "true");
const fractalServer = fractal.web.server({ const fractalServer = fractal.web.server({
sync: true sync: true
}); });
...@@ -150,27 +151,27 @@ module.exports = { ...@@ -150,27 +151,27 @@ module.exports = {
} }
// If you want to build static html files // If you want to build static html files
if (mode == 'build') { if (mode == "build") {
fractal.set('project.environment.production', 'true'); fractal.set("project.environment.production", "true");
const builder = fractal.web.builder(); const builder = fractal.web.builder();
builder.on('progress', (completed, total) => builder.on("progress", (completed, total) =>
logger.update(`Exported ${completed} of ${total} items`, 'info') logger.update(`Exported ${completed} of ${total} items`, "info")
); );
builder.on('error', err => logger.error(err.message)); builder.on("error", err => logger.error(err.message));
return builder.build().then(() => { return builder.build().then(() => {
logger.success('Fractal build completed!'); logger.success("Fractal build completed!");
callback(fractal); callback(fractal);
}); });
} }
// To build the fractal object in memory // To build the fractal object in memory
if (mode == 'dataobject') { if (mode == "dataobject") {
fractal.set('project.environment.production', 'true'); fractal.set("project.environment.production", "true");
const server = fractal.web.server(); const server = fractal.web.server();
server.start().then(function(){ server.start().then(function(){
console.log('The Fractal component data has been generated.'); console.log("The Fractal component data has been generated.");
callback(fractal); callback(fractal);
server.stop(); server.stop();
fractal.unwatch(); // exit fractal fractal.unwatch(); // exit fractal
...@@ -178,4 +179,4 @@ module.exports = { ...@@ -178,4 +179,4 @@ module.exports = {
} }
} }
} };
{ {
"name": "@visual-framework/vf-core", "name": "@visual-framework/vf-core",
"version": "2.2.34", "version": "2.2.36",
"description": "Common dependencies for the Visual Framework 2.0.", "description": "Common dependencies for the Visual Framework 2.0.",
"engines": { "engines": {
"node": ">=12.0.0" "node": ">=12.0.0"
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
"dependencies": { "dependencies": {
"@visual-framework/vf-component-generator": "^1.1.5", "@visual-framework/vf-component-generator": "^1.1.5",
"@visual-framework/vf-component-initialization": "^1.1.7", "@visual-framework/vf-component-initialization": "^1.1.7",
"@visual-framework/vf-frctl-extensions": "^1.0.1", "@visual-framework/vf-frctl-extensions": "^2.0.0",
"@visual-framework/vf-sass-compilation": "^1.1.16", "@visual-framework/vf-sass-compilation": "^1.1.16",
"chalk": "^4.0.0", "chalk": "^4.0.0",
"del": "^6.0.0", "del": "^6.0.0",
......
### 2.0.0
* Invoke marked with `renderMarkdown.parse` for compatibility with version 4.
### 1.0.1 ### 1.0.1
* Updates highlightjs syntax of codeblock tag * Updates highlightjs syntax of codeblock tag
......
...@@ -58,14 +58,14 @@ module.exports = function(fractal){ ...@@ -58,14 +58,14 @@ module.exports = function(fractal){
var body = body(); var body = body();
var spacesRegex = /^[\s]+/; var spacesRegex = /^[\s]+/;
var tabStart = tabStart(); // The column postion of the {% markdown %} tag. var tabStart = tabStart(); // The column position of the {% markdown %} tag.
if (tabStart > 0) { // If the {% markdown %} tag is tabbed in, normalize the content to the same depth. if (tabStart > 0) { // If the {% markdown %} tag is tabbed in, normalize the content to the same depth.
body = body.split(/\r?\n/); // Split into lines. body = body.split(/\r?\n/); // Split into lines.
body = body.map(function(line) { body = body.map(function(line) {
var startSpaces = line.match(spacesRegex); var startSpaces = line.match(spacesRegex);
if (startSpaces && startSpaces[0].length >= tabStart) { // If the content is not at the same or greater tab depth, do nothing.. if (startSpaces && startSpaces[0].length >= tabStart) { // If the content is not at the same or greater tab depth, do nothing..
return line.slice(tabStart); // Subtract the column postion from the start of the string. return line.slice(tabStart); // Subtract the column position from the start of the string.
} else if (startSpaces) { } else if (startSpaces) {
return line.slice(startSpaces[0].length); return line.slice(startSpaces[0].length);
} else { } else {
...@@ -75,8 +75,8 @@ module.exports = function(fractal){ ...@@ -75,8 +75,8 @@ module.exports = function(fractal){
body = body.join("\n"); // Rejoin into one string. body = body.join("\n"); // Rejoin into one string.
} }
return new nunjucks.runtime.SafeString(renderMarkdown(body));
}; };
return new nunjucks.runtime.SafeString(renderMarkdown.parse(body));
} }
......
{ {
"name": "@visual-framework/vf-frctl-extensions", "name": "@visual-framework/vf-frctl-extensions",
"version": "1.0.1", "version": "2.0.0",
"description": "Reusable componentised code, modules and config for Visual Framework based projects using Fractal.", "description": "Reusable componentised code, modules and config for Visual Framework based projects using Fractal.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
......
### 1.1.18
* Add now required @babel/core dependency.
### 1.1.17 ### 1.1.17
* Update @babel/preset-env to 7.16.4 * Update @babel/preset-env to 7.16.4
......
{ {
"name": "@visual-framework/vf-sass-compilation", "name": "@visual-framework/vf-sass-compilation",
"version": "1.1.17", "version": "1.1.18",
"description": "Build the Sass for Visual Framework 2.0 projects.", "description": "Build the Sass for Visual Framework 2.0 projects.",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
}, },
"private": false, "private": false,
"dependencies": { "dependencies": {
"@babel/core": "^7.16.0",
"@babel/preset-env": "7.16.4", "@babel/preset-env": "7.16.4",
"eslint": "^8.0.0", "eslint": "^8.0.0",
"gulp-autoprefixer": "^8.0.0", "gulp-autoprefixer": "^8.0.0",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment