MCPcopy Index your code
hub / github.com/TruthHun/BookStack / handleImg

Function handleImg

utils/html2md/html2markdown.go:279–292  ·  view source on GitHub ↗

[ok]handle tag

(doc *goquery.Document)

Source from the content-addressed store, hash-verified

277
278//[ok]handle tag <img/>
279func handleImg(doc *goquery.Document) *goquery.Document {
280 doc.Find("img").Each(func(i int, selection *goquery.Selection) {
281 if src, ok := selection.Attr("src"); ok {
282 alt := ""
283 if val, ok := selection.Attr("alt"); ok {
284 alt = val
285 }
286 md := fmt.Sprintf(`![%v](%v)`, alt, src)
287 selection.BeforeHtml(md)
288 selection.Remove()
289 }
290 })
291 return doc
292}
293
294//[ok]handle tag h1~h6
295func handleHead(doc *goquery.Document) *goquery.Document {

Callers 1

ConvertFunction · 0.85

Calls 1

FindMethod · 0.45

Tested by

no test coverage detected