mirror of
https://github.com/yuin/goldmark
synced 2025-03-04 23:04:52 +00:00
Ordered kv's in dumps
This commit is contained in:
parent
15ade8aace
commit
e1522faede
1 changed files with 12 additions and 2 deletions
12
ast/ast.go
12
ast/ast.go
|
|
@ -4,6 +4,7 @@ package ast
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
textm "github.com/yuin/goldmark/text"
|
textm "github.com/yuin/goldmark/text"
|
||||||
|
|
@ -449,8 +450,17 @@ func DumpHelper(v Node, source []byte, level int, kv map[string]string, cb func(
|
||||||
fmt.Printf("\"\n")
|
fmt.Printf("\"\n")
|
||||||
fmt.Printf("%sHasBlankPreviousLines: %v\n", indent2, v.HasBlankPreviousLines())
|
fmt.Printf("%sHasBlankPreviousLines: %v\n", indent2, v.HasBlankPreviousLines())
|
||||||
}
|
}
|
||||||
|
if len(kv) > 0 {
|
||||||
|
sortedKV := make([][2]string, 0, len(kv))
|
||||||
for name, value := range kv {
|
for name, value := range kv {
|
||||||
fmt.Printf("%s%s: %s\n", indent2, name, value)
|
sortedKV = append(sortedKV, [2]string{name, value})
|
||||||
|
}
|
||||||
|
sort.Slice(sortedKV, func(i, j int) bool {
|
||||||
|
return sortedKV[i][0] < sortedKV[j][0]
|
||||||
|
})
|
||||||
|
for _, kv := range sortedKV {
|
||||||
|
fmt.Printf("%s%s: %s\n", indent2, kv[0], kv[1])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if cb != nil {
|
if cb != nil {
|
||||||
cb(level + 1)
|
cb(level + 1)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue