@cdxoo/block-quote

1.0.1 • Public • Published

@cdxoo/block-quote

Simple indent sanitization for multi line strings via tag for template literals in es6.

Installation

npm install --save @cdxoo/block-quote

Usage

const bq = require('@cdxoo/block-quote');
    
let str1 = bq`
    alice
        foo
        bar
    bob
        baz
`;
//    | <- beginning of the line
// => |alice
//    |    foo
//    |    bar
//    |bob
//    |    baz

// also works when code itself is indented deeper
// and placeholders are used; e.g.:
let getInner = () => (
    (
        (
            bq`
                inner {
                    foo
                    bar
                }
            `
        )
    )
);
let str1 = bq`
    outer {
        ${ getInner() }
    }
`;
// => |outer {
//    |    inner {
//    |        foo
//    |        bar
//    |    }
//    |}

Readme

Keywords

Package Sidebar

Install

npm i @cdxoo/block-quote

Weekly Downloads

6

Version

1.0.1

License

MIT

Unpacked Size

6.52 kB

Total Files

5

Last publish

Collaborators

  • cdxoo