highlight.js-console

1.0.1 • Public • Published

highlight.js-console

Description

highlight.js-console is a node module to take the stylized output from highlight.js and make it convert the theming to work in a node command line.

Features

  • Preserves Whitespace
  • Will attempt to use bold/italics/underline
  • Will apply foreground and background colors
    • Colors often work, but may substitute down if chalk detects a non-true-color terminal

Installation

$ npm install highlight.js-console

Usage

Use highlight.js's highlightAuto() function to create the html output, then use highlight.js-console's convert function to convert the text to character codes.

var hljs = require('highlight.js');
var h2c = require('highlight.js-console'); 
var text = fs.readFileSync('test.html').toString();
var hlText = hljs.highlightAuto(text);
h2c.convert(hlText.value, 'vs')
  .then(function(converted) {
    console.log(converted);
  })
  .catch(function(ex) {
    console.error(ex);
  });

Troubleshooting

  • Make sure your terminal/emulator/network tool support this feature
  • Try a different theme - aggressive substitution makes some themes subtle or ineffective

TODO

  • Test with tabs?
  • Improve bgcolor coverage (full width)

License

Apache 2.0

Readme

Keywords

none

Package Sidebar

Install

npm i highlight.js-console

Weekly Downloads

0

Version

1.0.1

License

Apache-2.0

Unpacked Size

17.7 kB

Total Files

6

Last publish

Collaborators

  • shawngmc