Skip to content

Commit

Permalink
Merge branch 'version'
Browse files Browse the repository at this point in the history
  • Loading branch information
drudru committed May 16, 2015
2 parents 6dc1dd7 + 5754a92 commit 4a65ef4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
20 changes: 11 additions & 9 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,23 @@ There are examples in the repo that demonstrate an AMD/require.js/ jQuery exampl

## API

_ansi_up_ should be called via the functions defined on the module. It is recommended that the HTML is rendered with a monospace font and black background. See the examples, for a basic CSS definition.
_ansi_up_ should be called via the functions defined on the module. It is recommended that the HTML is rendered with a monospace font and black background. See the examples, for a basic theme as a CSS definition.

#### escape_for_html (txt)
#### ansi_to_html (txt, options)

This does the minimum escaping of text to make it compliant with HTML. In particular, the '&','<', and '>' characters are escaped.
This replaces ANSI terminal escape codes with SPAN tags that wrap the content. See the example output above.

#### linkify (txt)
This function only interprets ANSI SGR (Select Graphic Rendition) codes that can be represented in HTML. For example, cursor movement codes are ignored and hidden from output.

This replaces any links in the text with anchor tags that display the link. The links should have at least one whitespace character surrounding it. Also, you should apply this after you have run ansi_to_html on the text.
The default style uses colors that are very close to the prescribed standard. The standard assumes that the text will have a black background. These colors are set as inline styles on the SPAN tags. Another option is to set 'use_classes: true' in the options argument. This will instead set classes on the spans so the colors can be set via CSS. The class names used are of the format ````ansi-*-fg/bg```` and ````ansi-bright-*-fg/bg```` where * is the colour name, i.e black/red/green/yellow/blue/magenta/cyan/white. See the examples directory for a complete CSS theme for these classes.

#### ansi_to_html (txt, options)
#### escape_for_html (txt)

This replaces ANSI terminal escape codes with SPAN tags that wrap the content. By default the styles are inline on the SPAN tags.
This does the minimum escaping of text to make it compliant with HTML. In particular, the '&','<', and '>' characters are escaped. This should be run prior to ansi_to_html.

The options parameter is optional and if you pass an object with the key/value pair 'use_classes: true' classes will be set on the SPAN tag instead of inline styles. The classes used are of the format ````ansi-*-fg/bg```` and ````ansi-bright-*-fg/bg```` where * is the colour name, i.e black/red/green/yellow/blue/magenta/cyan/white.
#### linkify (txt)

This replaces any links in the text with anchor tags that display the link. The links should have at least one whitespace character surrounding it. Also, you should apply this after you have run ansi_to_html on the text.

## Building

Expand All @@ -84,10 +86,10 @@ This code was developed by Dru Nelson (<https://github.com/drudru>).

Thanks goes to the following contributors for their patches:

- AIZAWA Hina (<https://github.com/fetus-hina>)
- James R. White (<https://github.com/jamesrwhite>)
- Aaron Stone (<https://github.com/sodabrew>)
- Maximilian Antoni (<https://github.com/mantoni>)
- AIZAWA Hina (<https://github.com/fetus-hina>)


## License
Expand Down
4 changes: 2 additions & 2 deletions ansi_up.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// ansi_up.js
// version : 1.1.3
// version : 1.2.0
// author : Dru Nelson
// license : MIT
// http://github.com/drudru/ansi_up

(function (Date, undefined) {

var ansi_up,
VERSION = "1.1.3",
VERSION = "1.2.0",

// check for nodeJS
hasModule = (typeof module !== 'undefined'),
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ansi_up",
"main": "ansi_up.js",
"version": "1.1.3",
"version": "1.2.0",
"homepage": "https://github.com/drudru/ansi_up",
"authors": [
"drudru <drudru@gmail.com>"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ansi_up",
"version": "1.1.3",
"version": "1.2.0",
"description": "Convert ansi sequences in strings to colorful HTML",
"keywords": ["ansi", "html"],
"author": "drudru <drudru@gmail.com>",
Expand Down

0 comments on commit 4a65ef4

Please sign in to comment.