Merge pull request #11 from augustoroman/master

Reset attributes on each color set, add "dim" attribute.
diff --git a/README.md b/README.md
index 8f8e20b..05905ab 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,7 @@
 
 ```go
 Color(s, "red")            // red
+Color(s, "red+d")          // red dim
 Color(s, "red+b")          // red bold
 Color(s, "red+B")          // red blinking
 Color(s, "red+u")          // red underline
@@ -73,6 +74,7 @@
 * B = Blink
 * b = bold
 * h = high intensity (bright)
+* d = dim
 * i = inverse
 * s = strikethrough
 * u = underline
diff --git a/ansi.go b/ansi.go
index dc04136..9ab6979 100644
--- a/ansi.go
+++ b/ansi.go
@@ -24,9 +24,11 @@
 	highIntensityBG   = 100
 
 	start         = "\033["
+	normal        = "0;"
 	bold          = "1;"
-	blink         = "5;"
+	dim           = "2;"
 	underline     = "4;"
+	blink         = "5;"
 	inverse       = "7;"
 	strikethrough = "9;"
 
@@ -164,10 +166,14 @@
 
 	buf.WriteString(start)
 	base := normalIntensityFG
+	buf.WriteString(normal) // reset any previous style
 	if len(fgStyle) > 0 {
 		if strings.Contains(fgStyle, "b") {
 			buf.WriteString(bold)
 		}
+		if strings.Contains(fgStyle, "d") {
+			buf.WriteString(dim)
+		}
 		if strings.Contains(fgStyle, "B") {
 			buf.WriteString(blink)
 		}
diff --git a/ansi_test.go b/ansi_test.go
index 1630dc5..68fe85d 100644
--- a/ansi_test.go
+++ b/ansi_test.go
@@ -1,6 +1,7 @@
 package ansi
 
 import (
+	"fmt"
 	"strings"
 	"testing"
 )
@@ -50,3 +51,15 @@
 		t.Fail()
 	}
 }
+
+func TestAttributeReset(t *testing.T) {
+	boldRed := ColorCode("red+b")
+	greenUnderline := ColorCode("green+u")
+	s := fmt.Sprintf("normal %s bold red %s green underline %s", boldRed, greenUnderline, Reset)
+	// See the results on the terminal for regression tests.
+	fmt.Printf("Colored string: %s\n", s)
+	fmt.Printf("Escaped string: %q\n", s)
+	if s != "normal \x1b[0;1;31m bold red \x1b[0;4;32m green underline \x1b[0m" {
+		t.Error("Attributes are not being reset")
+	}
+}
diff --git a/doc.go b/doc.go
index 43c217e..c93039b 100644
--- a/doc.go
+++ b/doc.go
@@ -58,6 +58,7 @@
 	B = Blink foreground
 	u = underline foreground
 	h = high intensity (bright) foreground, background
+	d = dim foreground
 	i = inverse
 
 Wikipedia ANSI escape codes [Colors](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors)