How to use the marked-terminal.prototype function in marked-terminal

To help you get started, we’ve selected a few marked-terminal 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 crazyguitar / noslide.js / lib / slide.js View on Github external
});
    body = setLineSameWidth(body.trim());

    var quote = "";
    body.split('\n').forEach(line => {
      if (line.trim() === "") {
        quote += '\n';
        return;
      }
      quote += ('> ' + line + '\n');
    });
    return '\n' + this.o.blockquote(indentify(quote)) + '\n\n';
  });
};

TerminalRenderer.prototype.html = function(html) {
  var out = "";
  if (html instanceof Array) {
    html.forEach(block => {
      out += block;
    });
  } else {
    out = html;
  }
  out = out.replace(/<[^>\)\(]+>/g,'');
  return this.o.html(setLineSameWidth(out));
};



/**
 * Read slide content.
github crazyguitar / noslide.js / lib / slide.js View on Github external
var hasText = text && text !== href;

  var out = '';
  if (hasText) out += this.emoji(text) + ' (';
  out +=  this.o.href(href);
  if (hasText) out += ')';

  return this.o.link(out);
};

TerminalRenderer.prototype.hr = function() {
  return '\n\n' + '-'.repeat(this.o.width) + '\n';
};

TerminalRenderer.prototype.blockquote = function(quoteBlocks) {
  return Promise.all(quoteBlocks).then(quotes => {
    var body = "";
    quotes.forEach(quote => {
      body += quote;
    });
    body = setLineSameWidth(body.trim());

    var quote = "";
    body.split('\n').forEach(line => {
      if (line.trim() === "") {
        quote += '\n';
        return;
      }
      quote += ('> ' + line + '\n');
    });
    return '\n' + this.o.blockquote(indentify(quote)) + '\n\n';
github crazyguitar / noslide.js / lib / slide.js View on Github external
if (prot.indexOf('javascript:') === 0) {
      return '';
    }
  }

  var hasText = text && text !== href;

  var out = '';
  if (hasText) out += this.emoji(text) + ' (';
  out +=  this.o.href(href);
  if (hasText) out += ')';

  return this.o.link(out);
};

TerminalRenderer.prototype.hr = function() {
  return '\n\n' + '-'.repeat(this.o.width) + '\n';
};

TerminalRenderer.prototype.blockquote = function(quoteBlocks) {
  return Promise.all(quoteBlocks).then(quotes => {
    var body = "";
    quotes.forEach(quote => {
      body += quote;
    });
    body = setLineSameWidth(body.trim());

    var quote = "";
    body.split('\n').forEach(line => {
      if (line.trim() === "") {
        quote += '\n';
        return;
github crazyguitar / noslide.js / lib / slide.js View on Github external
if (Object.prototype.hasOwnProperty.call(target, key)) {
        obj[key] = target[key];
      }
    }
  }

  return obj;
}


TerminalRenderer.prototype.code = function(code, lang, escaped) {
  code = setLineSameWidth(code);
  return '\n' + indentify(highlight(code, lang, this.o, this.highlightOptions)) + '\n';
};

TerminalRenderer.prototype.list = function(body, ordered) {
  body = setLineSameWidth(body);
  body = indentLines(this.o.listitem(body));
  body = body + '\n';
  if (!ordered) return body;
  return changeToOrdered(body);
};

TerminalRenderer.prototype.image = function(href, title, text) {
  return new Promise((resolve, reject) => {
    imageToAscii(href,
      { size: { height: "60%" }
      }, (err, converted) => {
      if (err) reject(err);
      else resolve(converted + "\n");
    });
  });
github crazyguitar / noslide.js / lib / slide.js View on Github external
return changeToOrdered(body);
};

TerminalRenderer.prototype.image = function(href, title, text) {
  return new Promise((resolve, reject) => {
    imageToAscii(href,
      { size: { height: "60%" }
      }, (err, converted) => {
      if (err) reject(err);
      else resolve(converted + "\n");
    });
  });

};

TerminalRenderer.prototype.heading = function(text, level, raw) {
  text = this.transform(text.join(''));

  var prefix = this.o.showSectionPrefix ?
    (new Array(level + 1)).join('#')+' ' : '';
  text = prefix + text;
  if (this.o.reflowText) {
    text = reflowText(text, this.o.width, this.options.gfm);
  }
  if (level === 1) {
    return this.o.firstHeading(text) + '\n';
  }
  return '\n' + this.o.heading(text) + '\n';
};

TerminalRenderer.prototype.paragraph = function(texts) {
  return Promise.all(texts).then(data => {
github crazyguitar / noslide.js / lib / slide.js View on Github external
TerminalRenderer.prototype.code = function(code, lang, escaped) {
  code = setLineSameWidth(code);
  return '\n' + indentify(highlight(code, lang, this.o, this.highlightOptions)) + '\n';
};

TerminalRenderer.prototype.list = function(body, ordered) {
  body = setLineSameWidth(body);
  body = indentLines(this.o.listitem(body));
  body = body + '\n';
  if (!ordered) return body;
  return changeToOrdered(body);
};

TerminalRenderer.prototype.image = function(href, title, text) {
  return new Promise((resolve, reject) => {
    imageToAscii(href,
      { size: { height: "60%" }
      }, (err, converted) => {
      if (err) reject(err);
      else resolve(converted + "\n");
    });
  });

};

TerminalRenderer.prototype.heading = function(text, level, raw) {
  text = this.transform(text.join(''));

  var prefix = this.o.showSectionPrefix ?
    (new Array(level + 1)).join('#')+' ' : '';
github crazyguitar / noslide.js / lib / slide.js View on Github external
TerminalRenderer.prototype.heading = function(text, level, raw) {
  text = this.transform(text.join(''));

  var prefix = this.o.showSectionPrefix ?
    (new Array(level + 1)).join('#')+' ' : '';
  text = prefix + text;
  if (this.o.reflowText) {
    text = reflowText(text, this.o.width, this.options.gfm);
  }
  if (level === 1) {
    return this.o.firstHeading(text) + '\n';
  }
  return '\n' + this.o.heading(text) + '\n';
};

TerminalRenderer.prototype.paragraph = function(texts) {
  return Promise.all(texts).then(data => {
    var res = '';
    data.forEach(i => {
      res += i;
    });
    return '\n' + res + '\n';
  });
};

TerminalRenderer.prototype.link = function(href, title, text) {
  text = text.join('');
  var prot = "";
  if (this.options.sanitize) {
    try {
      prot = decodeURIComponent(unescape(href))
        .replace(/[^\w:]/g, '')
github crazyguitar / noslide.js / lib / slide.js View on Github external
return this.o.firstHeading(text) + '\n';
  }
  return '\n' + this.o.heading(text) + '\n';
};

TerminalRenderer.prototype.paragraph = function(texts) {
  return Promise.all(texts).then(data => {
    var res = '';
    data.forEach(i => {
      res += i;
    });
    return '\n' + res + '\n';
  });
};

TerminalRenderer.prototype.link = function(href, title, text) {
  text = text.join('');
  var prot = "";
  if (this.options.sanitize) {
    try {
      prot = decodeURIComponent(unescape(href))
        .replace(/[^\w:]/g, '')
        .toLowerCase();
    } catch (e) {
      return '';
    }
    if (prot.indexOf('javascript:') === 0) {
      return '';
    }
  }

  var hasText = text && text !== href;
github crazyguitar / noslide.js / lib / slide.js View on Github external
, key;

  for (; i < arguments.length; i++) {
    target = arguments[i];
    for (key in target) {
      if (Object.prototype.hasOwnProperty.call(target, key)) {
        obj[key] = target[key];
      }
    }
  }

  return obj;
}


TerminalRenderer.prototype.code = function(code, lang, escaped) {
  code = setLineSameWidth(code);
  return '\n' + indentify(highlight(code, lang, this.o, this.highlightOptions)) + '\n';
};

TerminalRenderer.prototype.list = function(body, ordered) {
  body = setLineSameWidth(body);
  body = indentLines(this.o.listitem(body));
  body = body + '\n';
  if (!ordered) return body;
  return changeToOrdered(body);
};

TerminalRenderer.prototype.image = function(href, title, text) {
  return new Promise((resolve, reject) => {
    imageToAscii(href,
      { size: { height: "60%" }

marked-terminal

A custom render for marked to output to the Terminal

MIT
Latest version published 2 months ago

Package Health Score

85 / 100
Full package analysis

Popular marked-terminal functions