Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@agrarium/plugin-markdown

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@agrarium/plugin-markdown

Agrarium plugin for markdown files resolving

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
Maintainers
2
Weekly downloads
 
Created
Source

Agrarium Markdown Plugin

Agrarium plugin for markdown files resolving.

Usage

npm i agrarium

Or use it standalone:

npm i @agrarium/plugin-markdown

In your .agrarium.js file:

const { PluginMarkdown } = require('agrarium');

module.exports = {
    src: ['./src/components'],
    plugins: [
        new PluginMarkdown({/* options */})
    ]
}

Example of result data

It returns content of markdown files in JSON. More info about PostHTMLTree here.

console.log(chunk.data)

{
    markdown: [{
        lang: 'en',
        content: [/* json */],
        file: {
            path: 'test/fixtures/blocks/test-block/test-block.md'
        }
    }, {
        lang: 'en',
        content: [/* json */],
        file: {
            path: 'test/fixtures/blocks/test-block/_mod/test-block_mod.md'
        }
    }]
}

Options

json?: boolean, default: true

Returns content in JSON.

html?: boolean, default: false

Returns content in HTML string.

namespace?: string, default: undefined

Adds prefix for parsed classes.

i18n: { langs: string[], default: string }, default: { langs: ['en'], default: 'en' }

Sets what langs you support in markdown. For example you can have: button.md and button.ru.md.

You need to set this option in your .agrarium.js file:

const { PluginMarkdown } = require('agrarium');

module.exports = {
    src: ['./src/components'],
    plugins: [
        new PluginMarkdown({
            i18n: {
                langs: ['en', 'ru'],
                default: 'en'
            }
        })
    ]
};

hooks

You can setup some hooks to modify markdown entites. It can be inline sources for example.

inlineSource?: (options: { lang: string, content: string }) => { src: string }

Parses inline sources in markdown and replace it with iframe. Example:

const builder = require('./builder');

agrarium({
    src: ['./src/components'],
    plugins: [
        new PluginMarkdown({
            hooks: {
                inlineSource({ lang, content } {
                    if (lang === 'js') {
                        builder(content);
                        return {
                            src: '/static/daweasc123da.html'
                        }
                    }
                }
            }
        })
    ]
});

License MIT

FAQs

Package last updated on 02 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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