Fix lint issues (#285)

* fix(lint): cascadeStyles always passed true

* fix(lint): gomnd
This commit is contained in:
Maas Lalani
2024-03-02 15:10:05 -05:00
committed by GitHub
parent e9956700ea
commit 61945eed41
5 changed files with 15 additions and 13 deletions
+6 -6
View File
@@ -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 {
+2 -2
View File
@@ -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
}
+1
View File
@@ -29,6 +29,7 @@ var (
l = len(s)
}
//nolint:gomnd
if len(values) > 2 {
r := values[2].(int)
if r > len(s) {
+4 -4
View File
@@ -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"),
@@ -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{
+2 -1
View File
@@ -7,6 +7,7 @@ import (
)
const defaultListIndent = 2
const defaultListLevelIndent = 4
const defaultMargin = 2
var (
@@ -31,7 +32,7 @@ var (
StyleBlock: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{},
},
LevelIndent: 4,
LevelIndent: defaultListLevelIndent,
},
Heading: ansi.StyleBlock{
StylePrimitive: ansi.StylePrimitive{