add support for transliteration
All checks were successful
mozhi pipeline / Push Docker image to Codeberg docker registry (push) Successful in 29m0s
mozhi pipeline / Build and publish artifacts (push) Successful in 1h1m0s

This commit is contained in:
2023-11-29 20:58:26 +05:30
parent 709e7c5ab9
commit b8c7be7a96
4 changed files with 42 additions and 26 deletions

View File

@@ -2,6 +2,7 @@ package serve
import (
"html/template"
"strings"
"log"
"net/http"
"os"
@@ -37,9 +38,8 @@ func Serve(port string) {
engine := html.NewFileSystem(views, ".html")
engine.AddFunc(
// Add unescape function. This is needed to render HTML from Markdown.
"unescape", func(s string) template.HTML {
return template.HTML(s)
"newlinetobr", func(s string) template.HTML {
return template.HTML(strings.ReplaceAll(strings.ReplaceAll(s, "\n", "<br>"), "\r", ""))
},
)