Added some more compatibilty

main
Uriel Fanelli 2025-05-05 15:34:37 +02:00
parent 1eaf0b12da
commit 2a52a8ec53
1 changed files with 6 additions and 5 deletions

11
page.go
View File

@ -2,19 +2,20 @@ package main
import ( import (
"bytes" "bytes"
"html"
"text/template" "text/template"
) )
func GenerateEpisodeDescription(imageURL, title, content string) string { func GenerateEpisodeDescription(imageURL, title, content string) string {
// Template con sezione CDATA // Template con sezione CDATA
const descTemplate = `<![CDATA[ const descTemplate = `
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<style> <style>
.episode-container { font-family: Arial, sans-serif; max-width: 800px; } .episode-container { font-family: Arial, sans-serif; max-width: 800px; }
.episode-image { float: right; margin: 0 0 15px 15px; max-width: 300px; } .episode-image { float: center; margin: 0 0 15px 15px; max-width: 300px; }
.episode-title { margin-top: 0; color: #333; } .episode-title { margin-top: 0; color: #333; }
.episode-content { line-height: 1.6; } .episode-content { line-height: 1.6; }
</style> </style>
@ -31,7 +32,7 @@ func GenerateEpisodeDescription(imageURL, title, content string) string {
</div> </div>
</body> </body>
</html> </html>
]]>` `
// Dati per il template // Dati per il template
data := struct { data := struct {
@ -50,8 +51,8 @@ func GenerateEpisodeDescription(imageURL, title, content string) string {
if err := tmpl.Execute(&buf, data); err != nil { if err := tmpl.Execute(&buf, data); err != nil {
// Fallback con CDATA // Fallback con CDATA
return "<![CDATA[<h3>" + title + "</h3>" + content + "]]>" return "<h3>" + title + "</h3>" + content + ">"
} }
return buf.String() return html.EscapeString(buf.String())
} }