How to use the trim-newlines function in trim-newlines

To help you get started, weā€™ve selected a few trim-newlines examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rocjs / roc / src / documentation / markdown / commandsToMarkdown.js View on Github external
function buildCommand(cli, command, commandData, allSettingGroups, printGroup, parents, level) {
    let rows = [];

    rows.push(`##${'#'.repeat(level)} ${command}`);

    if (commandData.description) {
        rows.push(`__${commandData.description}__`);
    }

    rows.push('');

    rows.push(`\`\`\`\n${cli} ${parents.concat(command).join(' ')}${getCommandArgumentsAsString(commandData)}\n\`\`\``);

    // If we have a markdown property we will use that over help
    if (commandData.markdown) {
        rows.push(redent(trimNewlines(commandData.markdown)));
    } else if (commandData.help) {
        rows.push(redent(trimNewlines(commandData.help)));
    }

    // Create table will Arguments + Command Options
    let body = [];

    // Generate the arguments
    if (commandData.arguments) {
        const objects = objectToArray(commandData.arguments).map((argument) => {
            const infoObject = getInfoObject(argument.validator);
            return {
                name: argument.name,
                description: argument.description || '',
                type: infoObject.type,
                required: infoObject.required,
github rocjs / roc / src / documentation / markdown / commandsToMarkdown.js View on Github external
rows.push(`##${'#'.repeat(level)} ${command}`);

    if (commandData.description) {
        rows.push(`__${commandData.description}__`);
    }

    rows.push('');

    rows.push(`\`\`\`\n${cli} ${parents.concat(command).join(' ')}${getCommandArgumentsAsString(commandData)}\n\`\`\``);

    // If we have a markdown property we will use that over help
    if (commandData.markdown) {
        rows.push(redent(trimNewlines(commandData.markdown)));
    } else if (commandData.help) {
        rows.push(redent(trimNewlines(commandData.help)));
    }

    // Create table will Arguments + Command Options
    let body = [];

    // Generate the arguments
    if (commandData.arguments) {
        const objects = objectToArray(commandData.arguments).map((argument) => {
            const infoObject = getInfoObject(argument.validator);
            return {
                name: argument.name,
                description: argument.description || '',
                type: infoObject.type,
                required: infoObject.required,
                canBeEmpty: infoObject.canBeEmpty,
                default: argument.default !== undefined && JSON.stringify(argument.default),
github GitbookIO / markup-it / src / markdown / blocks / code.js View on Github external
(state, match) => {
        // Extract code block text, and trim empty lines
        const text = trimNewlines(match[3]);

        // Extract language syntax
        let data;
        if (match[2]) {
            data = {
                syntax: unescape(match[2].trim())
            };
        }

        // Split lines
        const nodes = deserializeCodeLines(text);

        const node = Block.create({
            type: BLOCKS.CODE,
            nodes,
            data
github rocjs / roc / src / documentation / markdown / hooksToMarkdown.js View on Github external
extensionHooks.forEach((hook) => {
            const currentHook = hooks[extension][hook];

            rows.push(`### ${hook}`);

            if (currentHook.description) {
                rows.push('', redent(trimNewlines(currentHook.description)));
            }

            rows.push('');

            // eslint-disable-next-line
            rows.push('__Initial value:__ ' +
                (currentHook.initialValue ?
                    `\`${JSON.stringify(currentHook.initialValue)}\`` :
                    '_Nothing_')
                + '  '
            );

            // eslint-disable-next-line
            rows.push('__Expected return value:__ ' +
                (currentHook.returns ?
                    `\`${currentHook.returns(null, true).type}\`` :
github rocjs / roc / src / documentation / markdown / commandsToMarkdown.js View on Github external
function buildGroup(cli, command, commandData, allSettingGroups, printGroup, parents, level) {
    const rows = [];
    rows.push(`##${'#'.repeat(level)} ${command}`);
    if (commandData.__meta && commandData.__meta.name) {
        rows.push(`__${commandData.__meta.name}__`);
        rows.push('');
    }

    rows.push(`\`\`\`\n${cli} ${parents.concat(command).join(' ')} \n\`\`\``);
    if (commandData.__meta) {
        // If we have a markdown property we will use that over description
        if (commandData.__meta.markdown) {
            rows.push(redent(trimNewlines(commandData.__meta.markdown)), '');
        } else if (commandData.__meta.description) {
            rows.push(commandData.__meta.description, '');
        }
    }
    rows.push('');
    return rows;
}
github rocjs / roc / src / cli / commands / documentation / generateCommandDocumentation.js View on Github external
export default function generateCommandDocumentation(settings, metaSettings, metaCommands, command, name, parents) {
    const rows = [];
    rows.push(`Usage: ${name} ${parents.concat(command).join(' ')}` +
        getCommandArgumentsAsString(metaCommands[command]));
    rows.push('');

    if (metaCommands[command] && (metaCommands[command].description || metaCommands[command].help)) {
        if (metaCommands[command].help) {
            rows.push(redent(trimNewlines(metaCommands[command].help)));
        } else {
            rows.push(metaCommands[command].description);
        }

        rows.push('');
    }

    let body = [];

    // Generate the arguments table
    if (metaCommands[command] && metaCommands[command].arguments) {
        const objects = objectToArray(metaCommands[command].arguments).map((argument) => (
            {
                cli: `${argument.name}`,
                description: createDescription(argument),
            }
github rocjs / roc / test / cli / commands / documentation / generateCommandsDocumentation.js View on Github external
it('should render a correctly formatted table when no commands', () => {
                    expect(trimRight(stripAnsi(generateCommandsDocumentation({}, 'roc')))).toEqual(
                        redent(trimNewlines(`
                            Usage: roc 

                            Commands:
                             No commands available.

                            General options:
                             -b, --better-feedback   Enables source-map-support and loud-rejection.
                             -c, --config            Path to configuration file.
                             -d, --directory         Path to working directory.
                             -h, --help              Output usage information.
                             -V, --verbose           Enable verbose mode.
                             -v, --version           Output version number.
                            `
                        ))
                    );
                });
github dylang / logging / src / formatters / format-color / helpers / indented-box.ts View on Github external
export const indentedBox = (content: string, boxenOptions: Options) => {
    const columns = getColumns();
    return columns > 40
        ? indentAllLines(boxen(wrap(trimNewlines(content.trimRight()), getColumnsWithBoxen()), boxenOptions))
        : wrap(content, columns);
};
github rocjs / roc / src / documentation / markdown / extensionsToMarkdown.js View on Github external
packages.forEach((pkg) => {
            rows.push(`### ${pkg.name} ā€” [v${pkg.version}](https://www.npmjs.com/package/${pkg.name})`);
            const description = isFunction(pkg.description) ?
                pkg.description(commandObject, extension) :
                pkg.description && trimNewlines(redent(pkg.description));

            if (description) {
                rows.push(description);
            }

            rows.push('');
        });
    } else {

trim-newlines

Trim newlines from the start and/or end of a string

MIT
Latest version published 2 years ago

Package Health Score

67 / 100
Full package analysis

Popular trim-newlines functions