Skip to content

Commit

Permalink
Fix lint issues (#285)
Browse files Browse the repository at this point in the history
* fix(lint): cascadeStyles always passed true

* fix(lint): gomnd
  • Loading branch information
maaslalani committed Mar 2, 2024
1 parent e995670 commit 61945ee
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
12 changes: 6 additions & 6 deletions ansi/heading.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ func (e *HeadingElement) Render(w io.Writer, ctx RenderContext) error {

switch e.Level {
case h1:
rules = cascadeStyles(true, rules, ctx.options.Styles.H1)
rules = cascadeStyles(rules, ctx.options.Styles.H1)
case h2:
rules = cascadeStyles(true, rules, ctx.options.Styles.H2)
rules = cascadeStyles(rules, ctx.options.Styles.H2)
case h3:
rules = cascadeStyles(true, rules, ctx.options.Styles.H3)
rules = cascadeStyles(rules, ctx.options.Styles.H3)
case h4:
rules = cascadeStyles(true, rules, ctx.options.Styles.H4)
rules = cascadeStyles(rules, ctx.options.Styles.H4)
case h5:
rules = cascadeStyles(true, rules, ctx.options.Styles.H5)
rules = cascadeStyles(rules, ctx.options.Styles.H5)
case h6:
rules = cascadeStyles(true, rules, ctx.options.Styles.H6)
rules = cascadeStyles(rules, ctx.options.Styles.H6)
}

if !e.First {
Expand Down
4 changes: 2 additions & 2 deletions ansi/style.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ type StyleConfig struct {
HTMLSpan StyleBlock `json:"html_span,omitempty"`
}

func cascadeStyles(toBlock bool, s ...StyleBlock) StyleBlock {
func cascadeStyles(s ...StyleBlock) StyleBlock {
var r StyleBlock

for _, v := range s {
r = cascadeStyle(r, v, toBlock)
r = cascadeStyle(r, v, true)
}
return r
}
Expand Down
1 change: 1 addition & 0 deletions ansi/templatehelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ var (
l = len(s)
}

//nolint:gomnd
if len(values) > 2 {
r := values[2].(int)
if r > len(s) {
Expand Down
8 changes: 4 additions & 4 deletions dracula.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ var DraculaStyleConfig = ansi.StyleConfig{
BlockSuffix: "\n",
Color: stringPtr("#f8f8f2"),
},
Margin: uintPtr(2),
Margin: uintPtr(defaultMargin),
},
BlockQuote: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#f1fa8c"),
Italic: boolPtr(true),
},
Indent: uintPtr(2),
Indent: uintPtr(defaultMargin),
},
List: ansi.StyleList{
LevelIndent: 2,
LevelIndent: defaultMargin,
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#f8f8f2"),
Expand Down Expand Up @@ -115,7 +115,7 @@ var DraculaStyleConfig = ansi.StyleConfig{
StylePrimitive: ansi.StylePrimitive{
Color: stringPtr("#ffb86c"),
},
Margin: uintPtr(2),
Margin: uintPtr(defaultMargin),
},
Chroma: &ansi.Chroma{
Text: ansi.StylePrimitive{
Expand Down
3 changes: 2 additions & 1 deletion styles.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
)

const defaultListIndent = 2
const defaultListLevelIndent = 4
const defaultMargin = 2

var (
Expand All @@ -31,7 +32,7 @@ var (
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{},
},
LevelIndent: 4,
LevelIndent: defaultListLevelIndent,
},
Heading: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{
Expand Down

0 comments on commit 61945ee

Please sign in to comment.