fix quoted videos for telegram instant view too, like images.

This commit is contained in:
fiatjaf
2023-11-15 14:43:58 -03:00
parent 3732277241
commit 6b810d5ed1

View File

@@ -335,20 +335,18 @@ func basicFormatting(input string, skipNostrEventLinks bool, usingTelegramInstan
} }
imageReplacementTemplate := ` <img src="%s"> ` imageReplacementTemplate := ` <img src="%s"> `
videoReplacementTemplate := `<video controls width="100%%" class="max-h-[90vh] bg-neutral-300 dark:bg-zinc-700"><source src="%s"></video>`
if usingTelegramInstantView { if usingTelegramInstantView {
// telegram instant view doesn't like when there is an image inside a blockquote (like <p><img></p>) // telegram instant view doesn't like when there is an image inside a blockquote (like <p><img></p>)
// so we use this custom thing to stop all blockquotes before the images, print the images then // so we use this custom thing to stop all blockquotes before the images, print the images then
// start a new blockquote afterwards -- we do the same with the markdown renderer for <p> tags on mdToHtml // start a new blockquote afterwards -- we do the same with the markdown renderer for <p> tags on mdToHtml
imageReplacementTemplate = "</blockquote>" + imageReplacementTemplate + "<blockquote>" imageReplacementTemplate = "</blockquote>" + imageReplacementTemplate + "<blockquote>"
videoReplacementTemplate = "</blockquote>" + videoReplacementTemplate + "<blockquote>"
} }
lines := strings.Split(input, "\n") lines := strings.Split(input, "\n")
for i, line := range lines { for i, line := range lines {
line = replaceURLsWithTags(line, line = replaceURLsWithTags(line, imageReplacementTemplate, videoReplacementTemplate)
imageReplacementTemplate,
`<video controls width="100%%" class="max-h-[90vh] bg-neutral-300 dark:bg-zinc-700"><source src="%s"></video>`,
)
line = replaceNostrURLsWithTags(nostrMatcher, line) line = replaceNostrURLsWithTags(nostrMatcher, line)
lines[i] = line lines[i] = line
} }