Repository: alecthomas/chroma
Pull request #221 (2019-01-23 08:08:45)

Add additional information about style to README
When we discussed a recent pull request (#219), it came up that `chroma.Background` defines the default token style. And that tokens in a style file are hierarchical.

This pull request adds that information to the README file to clarify this for others. And to save explaining the same thing in the future again.


Patch:
diff --git a/README.md b/README.md
index b332721..d685ba4 100644
--- a/README.md
+++ b/README.md
@@ -213,6 +213,16 @@ Chroma styles use the [same syntax](http://pygments.org/docs/styles/) as Pygment
 
 All Pygments styles have been converted to Chroma using the `_tools/style.py` script.
 
+When you work with one of [Chroma's styles](https://github.com/alecthomas/chroma/tree/master/styles), know that the `chroma.Background` token type provides the default style for tokens. It does so by defining a foreground color and background color. 
+
+For example, this gives each token name not defined in the style a default color of `#f8f8f8` and uses `#000000` for the highlighted code block's background:
+
+~~~go
+chroma.Background: "#f8f8f2 bg:#000000",
+~~~
+
+Also, token types in a style file are hierarchical. For instance, when `CommentSpecial` is not defined, Chroma uses the token style from `Comment`. So when several comment tokens use the same color, you'll only need to define `Comment` and override the one that has a different color.
+
 For a quick overview of the available styles and how they look, check out the [Chroma Style Gallery](https://xyproto.github.io/splash/docs/).
 
 ## Command-line interface
diff --git a/lexers/c/csharp.go b/lexers/c/csharp.go
index d59fa4f..c6a5f46 100644
--- a/lexers/c/csharp.go
+++ b/lexers/c/csharp.go
@@ -13,6 +13,7 @@ var CSharp = internal.Register(MustNewLexer(
 		Filenames: []string{"*.cs"},
 		MimeTypes: []string{"text/x-csharp"},
 		DotAll:    true,
+		EnsureNL:  true,
 	},
 	Rules{
 		"root": {
diff --git a/lexers/t/tradingview.go b/lexers/t/tradingview.go
index e411411..1e64ab8 100644
--- a/lexers/t/tradingview.go
+++ b/lexers/t/tradingview.go
@@ -13,6 +13,7 @@ var TradingView = internal.Register(MustNewLexer(
 		Filenames: []string{"*.tv"},
 		MimeTypes: []string{"text/x-tradingview"},
 		DotAll:    true,
+		EnsureNL:  true,
 	},
 	Rules{
 		"root": {


Test patch:
diff --git a/lexers/testdata/csharp.actual b/lexers/testdata/csharp.actual
index 283f6d9..d30a0af 100644
--- a/lexers/testdata/csharp.actual
+++ b/lexers/testdata/csharp.actual
@@ -9,3 +9,5 @@ foreach (DriveInfo drive in drives)
     Console.WriteLine(dir);
   }
 }
+
+// Comment as last line should be recognised properly
\ No newline at end of file
diff --git a/lexers/testdata/csharp.expected b/lexers/testdata/csharp.expected
index 6799e22..a2a4baa 100644
--- a/lexers/testdata/csharp.expected
+++ b/lexers/testdata/csharp.expected
@@ -69,5 +69,6 @@
   {"type":"Punctuation","value":"}"},
   {"type":"Text","value":"\n"},
   {"type":"Punctuation","value":"}"},
-  {"type":"Text","value":"\n"}
+  {"type":"Text","value":"\n\n"},
+  {"type":"CommentSingle","value":"// Comment as last line should be recognised properly\n"}
 ]
diff --git a/lexers/testdata/tradingview.actual b/lexers/testdata/tradingview.actual
index 0bc340f..5447c47 100644
--- a/lexers/testdata/tradingview.actual
+++ b/lexers/testdata/tradingview.actual
@@ -10,3 +10,5 @@ plot(series=emaVal, style=circles, offset=2, linewidth=3)
 bgcolor(color=close > open ? orange :
      close != high[1] ? purple :
      na, transp=80)
+
+// Comment as last line should be recognised properly
\ No newline at end of file
diff --git a/lexers/testdata/tradingview.expected b/lexers/testdata/tradingview.expected
index 58fe5cf..962e265 100644
--- a/lexers/testdata/tradingview.expected
+++ b/lexers/testdata/tradingview.expected
@@ -89,5 +89,7 @@
   {"type":"Text","value":", transp"},
   {"type":"KeywordPseudo","value":"="},
   {"type":"LiteralNumber","value":"80"},
-  {"type":"Text","value":")\n"}
+  {"type":"Text","value":")\n\n"},
+  {"type":"CommentSingle","value":"// Comment as last line should be recognised properly"},
+  {"type":"Text","value":"\n"}
 ]