cbparser
v1.0.5
Published
A simple code block parser for extracting multiple codeblocks from text.
Downloads
4
Readme
CBParser : Code Block Parser
About
CBParser or Code Block parser is a parser to extract multiple code blocks from text, Specially Discord Code blocks.
- Completely Written in Typescript 🌟
- 0 Dependencies ✨
- Very Small in Size 🍫
- Easy to use 🍭
node ^v12
required.
Installation
Using npm:
npm install cbparser
using yarn:
yarn add cbparser
using pnpm:
pnpm add cbparser
Importing
const {CBParser} = require ('cbparser');
or using import :
import {CBParser} from 'cbparser';
Documentation:
Parameter:
str
: string
returns:
Array<[Object]>
lang
?: stringcode
: string
Example:
code:
const {CBParser} = require ('cbparser');
const code = "```js\nconsole.log('Hello Void!')```"
console.log(CBParser(code));
output:
[{lang:"js", code: "console.log('Hello Void!')"}]
Check out Regex being used to parse code blocks.