From c1b428de285cc97c30c8ed72b6ae24ccb2f31708 Mon Sep 17 00:00:00 2001 From: Niklas Fasching Date: Sun, 12 Mar 2023 11:25:44 +0100 Subject: [PATCH] html: Clean up and simplify code - we can use type casting to check for type instead of adding a dependency on reflect - lint complains about redundant types, so get rid of that for peace of mind --- org/html_writer.go | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/org/html_writer.go b/org/html_writer.go index ef27089..7449a04 100644 --- a/org/html_writer.go +++ b/org/html_writer.go @@ -4,7 +4,6 @@ import ( "fmt" "html" "log" - "reflect" "regexp" "strconv" "strings" @@ -50,20 +49,20 @@ type footnotes struct { } var emphasisTags = map[string][]string{ - "/": []string{"", ""}, - "*": []string{"", ""}, - "+": []string{"", ""}, - "~": []string{"", ""}, - "=": []string{``, ""}, - "_": []string{``, ""}, - "_{}": []string{"", ""}, - "^{}": []string{"", ""}, + "/": {"", ""}, + "*": {"", ""}, + "+": {"", ""}, + "~": {"", ""}, + "=": {``, ""}, + "_": {``, ""}, + "_{}": {"", ""}, + "^{}": {"", ""}, } var listTags = map[string][]string{ - "unordered": []string{""}, - "ordered": []string{"
    ", "
"}, - "descriptive": []string{"
", "
"}, + "unordered": {""}, + "ordered": {"
    ", "
"}, + "descriptive": {"
", "
"}, } var listItemStatuses = map[string]string{ @@ -646,7 +645,7 @@ func setHTMLAttribute(attributes []h.Attribute, k, v string) []h.Attribute { func isParagraphNodeSlice(ns []Node) bool { for _, n := range ns { - if reflect.TypeOf(n).Name() != "Paragraph" { + if _, ok := n.(Paragraph); !ok { return false } }