ministyle
Minimal semantic output styler API with default implementations.
A pluggable output styler/coloriser interface to embed in (development) tools and reporters. Offers a standard interface for customisable styled text output. The minimalistic API allows for overwrites to suit any environment.
Intend as companion to miniwrite (et al).
API
Main usage:
// standard console colorsvar ms = ministyle; // semantic stylers (and color conventions)var str = ms;var str = ms;var str = ms;var str = ms;var str = ms;var str = ms;var str = ms; // usageconsole;
Bundled implementations:
// defaultvar ms = ministyle;// return as-isvar ms = ministyle;// ansi terminal codesvar ms = ministyle; // html spans with default colorsvar ms = ministyle;// html spans with css classvar ms = ministyle; // colors.js gettersvar ms = ministyle;// grunt v0.4.xvar ms = ministyle; // blank charsvar ms = ministyle; // dev style wraps with [style:names])var ms = ministyle;
Advanced sub types
Apply each style in-order
// standard methods will pass the value though each sub-style and return the resultvar ms = ministyle;msenabled = true;msstack = ;
Peek and update string:
// standard methods pass value through callbackvar ms = ministyle
Toggle to alternative:
// standard methods will use main if enabled, otherwise altvar ms = ministyle
Build your own
var obj = { return str; } { return str; } { return str; } { return str; } { return str; } { return str; } { return str; };
Examples
Make it bigger:
var ms = ministyle;mserror = ms { return str;};
Safe html:
var ms = ministyle;
Installation
$ npm install ministyle --save
Future
- Code/style generator to replicate style-type logic (needs to be efficient though).
History
- 0.1.4 - Update to fix npm's README
- 0.1.2 - Added signal colour, enabled strict mode, split in internal modules
- 0.1.0 - Added tests, publishing to npm.
- 0.0.1 - Extracted styling from miniwrite.
Build
Install development dependencies in your git checkout:
$ npm install
Build and run tests:
$ grunt
See the Gruntfile.js
for additional commands.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
Note: this is an opinionated module: please create a ticket to discuss any big ideas. Pull requests for bug fixes are of course always welcome.
License
Copyright (c) 2013 Bart van der Schoor
Licensed under the MIT license.