diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-10-13 09:37:47 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-10-14 16:00:27 +0200 |
commit | 7c30e2cbb08fdf0e61f80c7f1aa29909aeca4211 (patch) | |
tree | c80336ec0905a23f0794f9c4d8dfb11f67fa5aba /helpers/pygments_test.go | |
parent | 60bd332c1f68e49e6ac439047e7c660865189380 (diff) |
Add table linenos support for Chroma highlighter
Fixes #3915
Diffstat (limited to 'helpers/pygments_test.go')
-rw-r--r-- | helpers/pygments_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/helpers/pygments_test.go b/helpers/pygments_test.go index e8a5199d9..860f317d8 100644 --- a/helpers/pygments_test.go +++ b/helpers/pygments_test.go @@ -111,6 +111,7 @@ func TestParseDefaultPygmentsArgs(t *testing.T) { type chromaInfo struct { classes bool lineNumbers bool + lineNumbersInTable bool highlightRangesLen int highlightRangesStr string baseLineNumber int @@ -120,8 +121,10 @@ func formatterChromaInfo(f *html.Formatter) chromaInfo { v := reflect.ValueOf(f).Elem() c := chromaInfo{} // Hack: - c.classes = v.FieldByName("classes").Bool() + + c.classes = f.Classes c.lineNumbers = v.FieldByName("lineNumbers").Bool() + c.lineNumbersInTable = v.FieldByName("lineNumbersInTable").Bool() c.baseLineNumber = int(v.FieldByName("baseLineNumber").Int()) vv := v.FieldByName("highlightRanges") c.highlightRangesLen = vv.Len() @@ -171,14 +174,19 @@ func TestChromaHTMLFormatterFromOptions(t *testing.T) { assert.Equal("[[1 1] [2 2] [3 3]]", c.highlightRangesStr) assert.Equal(1, c.baseLineNumber) }}, - {"linenos=sure,hl_lines=1,linenostart=4", nil, nil, "style=monokai,noclasses=false", func(c chromaInfo) { + {"linenos=inline,hl_lines=1,linenostart=4", nil, nil, "style=monokai,noclasses=false", func(c chromaInfo) { assert.True(c.classes) assert.True(c.lineNumbers) + assert.False(c.lineNumbersInTable) assert.Equal(1, c.highlightRangesLen) // This compansates for https://github.com/alecthomas/chroma/issues/30 assert.Equal("[[4 4]]", c.highlightRangesStr) assert.Equal(4, c.baseLineNumber) }}, + {"linenos=table", nil, nil, "style=monokai", func(c chromaInfo) { + assert.True(c.lineNumbers) + assert.True(c.lineNumbersInTable) + }}, {"style=monokai,noclasses=false", nil, nil, "style=manni,noclasses=true", func(c chromaInfo) { assert.True(c.classes) }}, |