fix link numbering
parent
34b1a118a3
commit
4858b0121b
12
main.go
12
main.go
|
@ -33,7 +33,10 @@ func _main(o opts) error {
|
||||||
output := string(t)
|
output := string(t)
|
||||||
footer := ""
|
footer := ""
|
||||||
|
|
||||||
|
linkIx := 0
|
||||||
|
|
||||||
for ix, lm := range linkMatches {
|
for ix, lm := range linkMatches {
|
||||||
|
linkIx = ix
|
||||||
rawLink := string(lm[0])
|
rawLink := string(lm[0])
|
||||||
link := string(lm[1])
|
link := string(lm[1])
|
||||||
title := string(lm[2])
|
title := string(lm[2])
|
||||||
|
@ -55,6 +58,7 @@ func _main(o opts) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ix, im := range imgMatches {
|
for ix, im := range imgMatches {
|
||||||
|
linkIx += ix
|
||||||
rawImg := string(im[0])
|
rawImg := string(im[0])
|
||||||
src := string(im[1])
|
src := string(im[1])
|
||||||
alt := string(im[2])
|
alt := string(im[2])
|
||||||
|
@ -63,12 +67,12 @@ func _main(o opts) error {
|
||||||
output = strings.ReplaceAll(output, rawImg,
|
output = strings.ReplaceAll(output, rawImg,
|
||||||
fmt.Sprintf("<img src=\"%s\" alt=\"%s\"/>", src, alt))
|
fmt.Sprintf("<img src=\"%s\" alt=\"%s\"/>", src, alt))
|
||||||
case "gopher":
|
case "gopher":
|
||||||
output = strings.ReplaceAll(output, rawImg, fmt.Sprintf("%s[%d]", alt, ix))
|
output = strings.ReplaceAll(output, rawImg, fmt.Sprintf("%s[%d]", alt, linkIx))
|
||||||
linkType := "p"
|
linkType := "p"
|
||||||
footer += fmt.Sprintf("%s[%d]: %s %s\n", linkType, ix, alt, src)
|
footer += fmt.Sprintf("%s[%d]: %s %s\n", linkType, linkIx, alt, src)
|
||||||
case "gemini":
|
case "gemini":
|
||||||
output = strings.ReplaceAll(output, rawImg, fmt.Sprintf("%s[%d]", alt, ix))
|
output = strings.ReplaceAll(output, rawImg, fmt.Sprintf("%s[%d]", alt, linkIx))
|
||||||
footer += fmt.Sprintf("=> %s [%d]: %s\n", src, ix, alt)
|
footer += fmt.Sprintf("=> %s [%d]: %s\n", src, linkIx, alt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue