patorjk / figlet.js

A FIG Driver written in JavaScript which aims to fully implement the FIGfont spec.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Option to disable prefix padding?

shellscape opened this issue · comments

It seems that figlet is always adding padding to the beginning of a rendered word. Using Larry 3D, this is the output for "node-framework":

                          __                      ___                                                              __
                         /\ \                   /'___\                                                            /\ \
          ___     ___    \_\ \     __          /\ \__/  _ __    __      ___ ___      __   __  __  __    ___   _ __\ \ \/'\
        /' _ `\  / __`\  /'_` \  /'__`\ _______\ \ ,__\/\`'__\/'__`\  /' __` __`\  /'__`\/\ \/\ \/\ \  / __`\/\`'__\ \ , <
        /\ \/\ \/\ \L\ \/\ \L\ \/\  __//\______\\ \ \_/\ \ \//\ \L\.\_/\ \/\ \/\ \/\  __/\ \ \_/ \_/ \/\ \L\ \ \ \/ \ \ \\`\
        \ \_\ \_\ \____/\ \___,_\ \____\/______/ \ \_\  \ \_\\ \__/.\_\ \_\ \_\ \_\ \____\\ \___x___/'\ \____/\ \_\  \ \_\\_\
         \/_/\/_/\/___/  \/__,_ /\/____/          \/_/   \/_/ \/__/\/_/\/_/\/_/\/_/\/____/ \/__//__/   \/___/  \/_/   \/_/\/_/

Why is there a poopton of padding at the start of each line, and how can we turn that off?

I agree, there shouldn't be that padding there. I'll take a look when I get a chance. I'm also open to pull requests if you want to take a look.

I took a look last night, but I'm lost in that code (and I work with AST stuff on a regular basis :)) not saying it's bad by any means or ways, I'm not able to grok it. "it's not you, it's me, but really"

In the mean time I'm using this snippet:

    banner = banner.replace(/\s+$/gm, '');

    lines = banner.split('\n');

    lines.forEach(function (line) {
      var matches = line.match(/^\s+/gi);

      if (matches && matches.length && leading.length > matches[0].length) {
        leading = matches[0];
      }
    });

    banner = banner.replace(new RegExp('^\\s{' + leading.length + '}', 'gm'), ' ');