New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details → →
Socket
Book a DemoSign in
Socket

@weh/markdown

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@weh/markdown

đź”» Markdown parsing plugin for the weh static site generator

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
2
Created
Source

@weh/markdown

A Markdown parsing plugin for the weh static site generator

npm version code style: standard

Features

  • Parse Markdown content in text files within the weh files array
  • Custom filter functions to include or exclude files from transforms

Installation

npm install --save @weh/markdown

Usage example

const weh = require('@weh/weh')
const markdown = require('@weh/markdown')

// enter our main function:
// the main function should be an async function so that
// it automatically returns a promise
weh(async site => {
  // we register our plugin...
  site.use(markdown)
  // ...and initiate the build process
  return site
})

Filter example

You can pass a custom filter as an option to markdown to include or exclude files.

A filter is a function that takes the arguments file, options, and files. file is the current file, options is the options object passed to markdown, and files is the entire array of files created by weh.

If the filter function returns true, markdown applies its transforms to the contents of the current file object. Otherwise the file object remains unchanged.

The default filter in markdown returns true only for files ending with .md:

function myCustomFilter (file, options, files) {
  return file.path.endsWith('.md')
}

This is how you could use a filter to apply markdown to every file:

const weh = require('@weh/weh')
const markdown = require('@weh/markdown')

// custom filter function
// always returns true
function myCustomFilter (file, options, files) {
  return true
}

weh(async site => {
  // we register the markdown plugin with our custom filter function...
  site.use(markdown, {filter: myCustomFilter})
  // ...and initiate the build process
  return site
})

All processed files are renamed to <filename>.html after being converted.

Maintainers

License

MIT (see LICENSE document)

Keywords

markdown

FAQs

Package last updated on 20 Sep 2017

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