Skip to content

ES6 string splitting by annotated comments. Parse blocks of text wrapped in annotated comments to JS object.

License

Notifications You must be signed in to change notification settings

rjjakes/parse-annotation-blocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

parse-annotation-blocks

ES6 string splitting by annotated comments. Parse blocks of text wrapped in annotated comments to a JS object.

For example, if your string contains:

/* @start someKey */ 
Some content 
/* @end someKey */ 

The module will extract the text between the @start and @end comments and return an object like:

{
    someKey: "Some content" 
}

Installation

npm install parse-annotation-blocks 

or

yarn add parse-annotation-blocks

Usage

An example:

let parseAnnotations = require('parse-annotation-blocks');

let string = `
  /* @start firstKey */  
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  /* @end firstKey */

  
  /* @start secondKey */
  Sed at est pellentesque ante ultricies aliquet aliquam a tellus. Donec eget urna velit. Mauris ac scelerisque lacus. 
  /* @end secondKey */
  
  This is outside a comment @start and @end block, so won't get included in the returned object. 
  `

let outputObject = parseAnnotations(string);

Credits

https://github.com/rjjakes

License

MIT

About

ES6 string splitting by annotated comments. Parse blocks of text wrapped in annotated comments to JS object.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published