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

remark-burger

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-burger

extracts text sandwiched between markers

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
1.2K
-18.47%
Maintainers
1
Weekly downloads
 
Created
Source

remark-burger 🍔

A remark plugin that extracts text sandwiched between 2 customizable markers & turns it into a node. A transformer or stringify function can then do whatever with the new node type.

yarn add remark-burger
npm install remark-burger
const burger = require('remark-burger')

remark()
  .use(burger)
  .parse('hello [[world]]')

//
//  { type: 'patty',
//    value: '',
//    data: { content: 'world' },
//    position: {
//      start: { line: 1, column: 7, offset: 6 },
//      end: { line: 1, column: 14, offset: 13 },
//      indent: [] } }

Options

interface RemarkBurgerOptions {
  beginMarker?: string;
  endMarker?: string;
  pattyName?: string;
  onlyRunWithMarker?: boolean;
  insertBefore?: MarkdownMethods;
}

beginMarker & endMarker

The default pair is [[ & ]].

remark()
  .use(burger, {
    beginMarker: '<<',
    endMarker: '>>',
  })
  .parse('hello <<world>>')

If the marker pair conflicts with markdown default syntax, it won't work. For example, this won't work:

remark()
  .use(burger, {
    beginMarker: '`',
    endMarker: '`',
  })
  .parse('hello `world`')

It is because by default, remark-burger's tokenizer priority is very low so it won't be conflicted with markdown syntax. This can be configured with insertBefore options.

pattyName

The default name is patty, but it can be configured to be whatever.

onlyRunWithMarker

This plugin won't run if no marker is declared. Default: false. The example below won't work:

// doesn't work
remark()
  .use(burger, {
    onlyRunWithMarker: true
  })
  .parse('hello [[world]]')

insertBefore

Change the order in which the parser will call this plugin's tokenizer. Here's the order list:

escape
autoLink
url
html
link
reference
strong
emphasis
deletion
code
break
<- remark-burger ->
text

By default, remark-burger's tokenizer is run before text. You can change this by passing in one of the method listed above. For example, this works:

remark()
  .use(burger, {
    beginMarker: '`',
    endMarker: '`',
    insertBefore: 'code',
  })
  .parse('hello `world`')

Keywords

remark

FAQs

Package last updated on 07 Oct 2019

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