New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markdown-magic

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markdown-magic - npm Package Compare versions

Comparing version 0.0.1 to 0.0.4

examples/generate-readme.js

2

examples/package.json
{
"name": "markdown-steroids-usage-example",
"name": "markdown-magic-usage-example",
"version": "1.0.0",

@@ -4,0 +4,0 @@ "description": "Usage example",

/**
* Custom Transform Plugin example
*/
const merge = require('deepmerge')
module.exports = function customPlugin(pluginOptions) {
// set plugin defaults
const defaultOptions = {

@@ -9,29 +12,9 @@ addNewLine: false

const userOptions = pluginOptions || {}
const pluginConfig = mergeOptions(defaultOptions, userOptions)
console.log('pluginConfig', pluginConfig)
const pluginConfig = merge(defaultOptions, userOptions)
// return the transform function
return function (content, options) {
// console.log('content', content)
// console.log(arguments)
const newLine = (pluginConfig.addNewLine) ? '\n' : ''
const updatedContent = content + newLine
console.log('return', updatedContent)
return updatedContent
}
}
/**
* Overwrites pluginDefaults's values with userDefinedOptions's and adds userDefinedOptions's if non existent in pluginDefaults
* @param pluginDefaults
* @param userDefinedOptions
* @returns obj3 a new object based on pluginDefaults and userDefinedOptions
*/
function mergeOptions(pluginDefaults, userDefinedOptions) {
const obj3 = {}
for (var attrname in pluginDefaults) {
obj3[attrname] = pluginDefaults[attrname]
}
for (var attrname in userDefinedOptions) {
obj3[attrname] = userDefinedOptions[attrname]
}
return obj3
}
{
"name": "markdown-magic",
"version": "0.0.1",
"version": "0.0.4",
"description": "Automatically update markdown files with content from external sources",
"main": "index.js",
"scripts": {
"docs": "node examples/generate-docs.js",
"docs": "node examples/generate-readme.js",
"test": "ava --verbose",

@@ -9,0 +9,0 @@ "lint": "eslint .",

@@ -24,8 +24,3 @@ # Markdown Magic

<!-- ⛔️ AUTO-GENERATED-CONTENT:START (pluginExample) DO not edit ⛔️ -->
lolloll
<!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
<!-- AUTO-GENERATED-CONTENT:START (RENDERDOCS:path=../index.js)
<!-- ⛔️ AUTO-GENERATED-CONTENT:START (RENDERDOCS:path=../index.js)
- Do not remove or modify this section -->

@@ -45,3 +40,3 @@ ### Function signature

`outputPath` - *string* - (optional) Change output path of new content. Default behavior is replacing the original file
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section -->
<!-- ⛔️ AUTO-GENERATED-CONTENT:END - Do not remove or modify this section -->

@@ -52,3 +47,3 @@ ### Transforms

<!-- AUTO-GENERATED-CONTENT:START (RENDERDOCS:path=../transforms/index.js) - Do not remove or modify this section -->
<!-- ⛔️ AUTO-GENERATED-CONTENT:START (RENDERDOCS:path=../transforms/index.js) - Do not remove or modify this section -->
### - `CODE`

@@ -84,3 +79,3 @@

---
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section -->
<!-- ⛔️ AUTO-GENERATED-CONTENT:END - Do not remove or modify this section -->

@@ -95,4 +90,4 @@ ## Custom Transforms

<!-- AUTO-GENERATED-CONTENT:START (CODE:src=./examples/generate-docs.js) -->
<!-- The below code snippet is automatically added from ./examples/generate-docs.js -->
<!-- ⛔️ AUTO-GENERATED-CONTENT:START (CODE:src=./examples/generate-readme.js) -->
<!-- The below code snippet is automatically added from ./examples/generate-readme.js -->
```js

@@ -103,4 +98,3 @@ const fs = require('fs')

const execSync = require('child_process').execSync
// require('markdown-steriods') lib
const markdownMagic = require('../index')
const markdownMagic = require('../index') // 'markdown-magic'

@@ -152,22 +146,51 @@ const config = {

```
<!-- AUTO-GENERATED-CONTENT:END -->
<!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
## Plugin Example:
<!-- ⛔️ AUTO-GENERATED-CONTENT:START (CODE:src=./examples/plugin-example.js) -->
<!-- The below code snippet is automatically added from ./examples/plugin-example.js -->
```js
/**
* Custom Transform Plugin example
*/
const merge = require('deepmerge')
module.exports = function customPlugin(pluginOptions) {
// set plugin defaults
const defaultOptions = {
addNewLine: false
}
const userOptions = pluginOptions || {}
const pluginConfig = merge(defaultOptions, userOptions)
// return the transform function
return function (content, options) {
const newLine = (pluginConfig.addNewLine) ? '\n' : ''
const updatedContent = content + newLine
return updatedContent
}
}
```
<!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
[View the raw file](https://raw.githubusercontent.com/DavidWells/markdown-magic/master/README.md) file and run `npm run docs` to see this plugin run
<!-- ⛔️ AUTO-GENERATED-CONTENT:START (pluginExample) DO not edit ⛔️ -->
This content is altered by the `pluginExample` plugin registered in `examples/generate-readme.js`
<!-- ⛔️ AUTO-GENERATED-CONTENT:END -->
## Other usage examples:
- [Serverless Community Plugin Repo](https://github.com/serverless/community-plugins/blob/master/generate-docs.js)
- [Serverless Community Plugin Repo](https://github.com/serverless/community-plugins/blob/master/generate-readme.js) this example takes a `json` file and converts it into a github flavored markdown table
## Demo
View the raw source of this `README.md` file to see the comment block and see how the `customTransform` function in `examples/generate-docs.js` works
View the raw source of this `README.md` file to see the comment block and see how the `customTransform` function in `examples/generate-readme.js` works
<!-- AUTO-GENERATED-CONTENT:START (customTransform:optionOne=hi&optionOne=DUDE) - Do not remove or modify this section -->
<!-- ⛔️ AUTO-GENERATED-CONTENT:START (customTransform:optionOne=hi&optionOne=DUDE) - Do not remove or modify this section -->
This will replace all the contents of inside the comment DUDE
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section -->
<!-- ⛔️ AUTO-GENERATED-CONTENT:END - Do not remove or modify this section -->
<!-- AUTO-GENERATED-CONTENT:START -->
what
<!-- AUTO-GENERATED-CONTENT:END -->
## Prior Art
This was inspired by [Kent C Dodds](https://twitter.com/kentcdodds) and [jfmengels](https://github.com/jfmengels)'s [all contributors cli](https://github.com/jfmengels/all-contributors-cli) project.

@@ -9,6 +9,6 @@ # Test Fixture

<!-- AUTO-GENERATED-CONTENT:START (CODE:src=https://raw.githubusercontent.com/DavidWells/markdown-steroids/master/example/generate-docs.js) -->
<!-- AUTO-GENERATED-CONTENT:START (CODE:src=https://raw.githubusercontent.com/DavidWells/markdown-magic/master/examples/generate-readme.js) -->
Remote code block will go here
<!-- AUTO-GENERATED-CONTENT:END -->
This is normal text in markdown. Keep it.
This is normal text in markdown. Keep it.

@@ -5,5 +5,5 @@ # Remote Transform

<!-- AUTO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/DavidWells/markdown-steroids/master/README.md) - Do not remove or modify this section -->
<!-- AUTO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/DavidWells/markdown-magic/master/README.md) - Do not remove or modify this section -->
All of this content will be replaced with remote content from https://raw.githubusercontent.com/DavidWells/markdown-steroids/master/README.md
All of this content will be replaced with remote content from https://raw.githubusercontent.com/DavidWells/markdown-magic/master/README.md

@@ -10,0 +10,0 @@ via the `REMOTE` transform

@@ -394,2 +394,74 @@ # Test Fixture

<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END - Do not remove or modify this section. Make all updates to plugins.json -->
### [Add your plugin to the list](https://github.com/serverless/community-plugins/edit/master/plugins.json)
After adding your plugin to the `plugins.json` file, run `npm run docs` to regenerate the plugin list table in the `readme.md` file.
<!-- AUTO-GENERATED-CONTENT:END

@@ -396,0 +468,0 @@ - Do not remove or modify this section. Make all updates to plugins.json -->

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc