mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-18 14:54:24 +01:00
fix quoted videos for telegram instant view too, like images.
This commit is contained in:
8
utils.go
8
utils.go
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user