markdown-magic
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -25,3 +25,5 @@ const fs = require('fs') | ||
/* Match AUTO-GENERATED-CONTENT (pluginExample) */ | ||
pluginExample: require('./plugin-example')({ addNewLine: true }) | ||
pluginExample: require('./plugin-example')({ addNewLine: true }), | ||
// count: require('markdown-magic-wordcount'), | ||
// github: require('markdown-magic-github-contributors') | ||
} | ||
@@ -28,0 +30,0 @@ } |
@@ -9,5 +9,3 @@ /* | ||
const openingTag = getOpeningTags(block, config) | ||
// console.log(openingTag) | ||
const closingTag = getClosingTags(block, config) | ||
// console.log(closingTag) | ||
@@ -25,6 +23,11 @@ if (!openingTag.transform) { | ||
const cmdOptions = openingTag.transform.cmdOptions | ||
// check if command exists | ||
if (cmd && config.transforms && config.transforms[cmd]) { | ||
const filteredContent = config.transforms[cmd](originalContent, cmdOptions, config) | ||
newContent = filteredContent | ||
let updatedContent = config.transforms[cmd](originalContent, cmdOptions, config) | ||
if (typeof updatedContent === 'function') { | ||
// if plugin has no options defined, invoke it with defaults | ||
updatedContent = updatedContent(originalContent, cmdOptions, config) | ||
} | ||
newContent = updatedContent | ||
if (!newContent) { | ||
@@ -31,0 +34,0 @@ console.log(`COMMAND '${cmd}' is returning undefined value. using original content instead. Make sure you return a value from your transform`) |
{ | ||
"name": "markdown-magic", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Automatically update markdown files with content from external sources", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -135,2 +135,3 @@ # Markdown Magic | ||
* [wordcount](https://github.com/DavidWells/markdown-magic-wordcount/) - Add wordcount to markdown files | ||
* [github-contributors](https://github.com/DavidWells/markdown-magic-github-contributors) - List out the contributors of a given repository | ||
@@ -174,3 +175,5 @@ ## Custom Transforms | ||
/* Match AUTO-GENERATED-CONTENT (pluginExample) */ | ||
pluginExample: require('./plugin-example')({ addNewLine: true }) | ||
pluginExample: require('./plugin-example')({ addNewLine: true }), | ||
// count: require('markdown-magic-wordcount'), | ||
// github: require('markdown-magic-github-contributors') | ||
} | ||
@@ -177,0 +180,0 @@ } |
42547
623
254