fix: linter errors (#263)

* refactor: extract magic numbers to const

* fix: linter errors
This commit is contained in:
Maas Lalani
2023-10-02 19:28:35 -07:00
committed by GitHub
parent ea723982eb
commit 0aaa280081
7 changed files with 40 additions and 130 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ func (s BlockStack) Margin() uint {
return i
}
// Width returns the available rendering width
// Width returns the available rendering width.
func (s BlockStack) Width(ctx RenderContext) uint {
if s.Indent()+s.Margin()*2 > uint(ctx.options.WordWrap) {
return 0
+15 -6
View File
@@ -14,22 +14,31 @@ type HeadingElement struct {
First bool
}
const (
h1 = iota + 1
h2
h3
h4
h5
h6
)
func (e *HeadingElement) Render(w io.Writer, ctx RenderContext) error {
bs := ctx.blockStack
rules := ctx.options.Styles.Heading
switch e.Level {
case 1:
case h1:
rules = cascadeStyles(true, rules, ctx.options.Styles.H1)
case 2:
case h2:
rules = cascadeStyles(true, rules, ctx.options.Styles.H2)
case 3:
case h3:
rules = cascadeStyles(true, rules, ctx.options.Styles.H3)
case 4:
case h4:
rules = cascadeStyles(true, rules, ctx.options.Styles.H4)
case 5:
case h5:
rules = cascadeStyles(true, rules, ctx.options.Styles.H5)
case 6:
case h6:
rules = cascadeStyles(true, rules, ctx.options.Styles.H6)
}
+1 -1
View File
@@ -9,7 +9,7 @@ type ImageElement struct {
Text string
BaseURL string
URL string
Child ElementRenderer // FIXME
Child ElementRenderer
}
func (e *ImageElement) Render(w io.Writer, ctx RenderContext) error {
+1 -1
View File
@@ -10,7 +10,7 @@ type LinkElement struct {
Text string
BaseURL string
URL string
Child ElementRenderer // FIXME
Child ElementRenderer
}
func (e *LinkElement) Render(w io.Writer, ctx RenderContext) error {
+1 -1
View File
@@ -6,7 +6,7 @@ import (
"text/template"
)
// TemplateFuncMap contains a few useful template helpers
// TemplateFuncMap contains a few useful template helpers.
var (
TemplateFuncMap = template.FuncMap{
"Left": func(values ...interface{}) string {