Skip to content

Commit

Permalink
Merge pull request #3 from nickarellano/main
Browse files Browse the repository at this point in the history
Dark Mode support example
  • Loading branch information
octoper authored Sep 27, 2022
2 parents 6e49792 + 57231f7 commit 1b4372f
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions payloads/DumpPayload.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
package payloads

import (
"strings"

"github.com/davecgh/go-spew/spew"
"github.com/gomarkdown/markdown"
)

// NewDumpPayload creates a new Dump Payload
func NewDumpPayload(value interface{}) Payload {
style := `
<style>
.go-dump pre {
position:relative;
overflow-x: auto;
width: 100%;
padding: 10px 10px;
height: auto;
background-color: #f3f3f3;
}
</style>`
md := []byte("``` \n"+spew.Sdump(value)+"\n```")
md := []byte("``` \n" + spew.Sdump(value) + "\n```")
output := markdown.ToHTML(md, nil, nil)
return NewCustomPayload(style+`<div class="go-dump">`+string(output) + "</div>", "")
styledOutput := strings.Replace(string(output), "<pre><code>", strings.Join([]string{
`<pre class="relative overflow-x-auto w-full p-5 h-auto bg-gray-100 dark:bg-gray-800">`,
`<code class="h-auto">`,
}, ""), 1)
return NewCustomPayload(styledOutput, "")
}

0 comments on commit 1b4372f

Please sign in to comment.