0.0.1 • Published 7 years ago

sindent v0.0.1

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

sindent

Remove indentation from string literals in a predictable manner using template tags.

const sindent = require('sindent')

sindent`This string
  should only indent
    right here
  but nowhere else,
  as it's obvious we don't want
  the other indentations`

// This string
// should only indent
//   right here
// but nowhere else
// as it's obvious we don't want
// the other indentations

Greedy mode

This "mode" makes the internal regex nice and hungry, so it'll accept an indentation of 0 as the smallest it finds. This isn't usually what you want, but it fits certain cases.

const sindent = require('sindent/greedy')

sindent`This line will be matched as the smallest,
  so this line will be indented`

// This line will be matched as the smallest
//   so this line will be indented

Function mode

If you don't want to use template tags, you can also use sindent as a normal function, accepting str and greedy.

const sindent = require('sindent/func')

sindent(`Let's start
  a greedy,
    greedy
indent`, true)

// Let's start
//   a greedy
//     greedy
// indent