+34
appview/pages/markup/markdown.go
+34
appview/pages/markup/markdown.go
···
5
5
"bytes"
6
6
"fmt"
7
7
"io"
8
+
"log"
8
9
"net/url"
9
10
"path"
10
11
"strings"
···
20
21
"github.com/yuin/goldmark/text"
21
22
"github.com/yuin/goldmark/util"
22
23
htmlparse "golang.org/x/net/html"
24
+
"golang.org/x/net/html/atom"
23
25
24
26
"tangled.sh/tangled.sh/core/appview/pages/repoinfo"
25
27
)
···
144
146
node.Attr[i] = attr
145
147
}
146
148
}
149
+
}
150
+
151
+
if node.Data == "pre" {
152
+
log.Println("found pre yahooooo!!")
153
+
button := &htmlparse.Node{
154
+
Type: htmlparse.ElementNode,
155
+
DataAtom: atom.Button,
156
+
Data: "button",
157
+
// Attr: []htmlparse.Attribute{
158
+
// {
159
+
// Key: "onclick",
160
+
// Val: "navigator.clipboard.writeText(this.parentElement.parentElement.querySelector('code').innerText)",
161
+
// },
162
+
// {
163
+
// Key: "onload",
164
+
// Val: "this.removeAttribute('aria-hidden')",
165
+
// },
166
+
// {
167
+
// Key: "aria-hidden",
168
+
// Val: "true",
169
+
// },
170
+
// },
171
+
}
172
+
173
+
button.AppendChild(
174
+
&htmlparse.Node{
175
+
Type: htmlparse.TextNode,
176
+
Data: "Copy",
177
+
},
178
+
)
179
+
180
+
node.InsertBefore(button, node)
147
181
}
148
182
149
183
for n := node.FirstChild; n != nil; n = n.NextSibling {