aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2023-04-10 20:57:54 +0300
committerArthur Zamarin <arthurzam@gentoo.org>2023-04-10 20:58:32 +0300
commitaf74d483c4bd89e733379876f6185a4c9118a646 (patch)
treee5221b79024d16f73665f5d881ce04d463f4f7c2 /pkg
parentupdate node dependencies (diff)
downloadsoko-af74d483c4bd89e733379876f6185a4c9118a646.tar.gz
soko-af74d483c4bd89e733379876f6185a4c9118a646.tar.bz2
soko-af74d483c4bd89e733379876f6185a4c9118a646.zip
app/packages/show: better rendering of newlines in description
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/app/handler/packages/utils.go3
-rw-r--r--pkg/portage/repository/deprecated.go6
-rw-r--r--pkg/portage/repository/mask.go6
3 files changed, 13 insertions, 2 deletions
diff --git a/pkg/app/handler/packages/utils.go b/pkg/app/handler/packages/utils.go
index 0456c14..eeafc36 100644
--- a/pkg/app/handler/packages/utils.go
+++ b/pkg/app/handler/packages/utils.go
@@ -203,6 +203,9 @@ func GetFuncMap() template.FuncMap {
"showRemovalNotice": showRemovalNotice,
"isDeprecated": isDeprecated,
"getDeprecation": getDeprecation,
+ "replaceNewline": func(s string) template.HTML {
+ return template.HTML(strings.Replace(template.HTMLEscapeString(s), "\n", "<br>", -1))
+ },
"add": func(a, b int) int {
return a + b
},
diff --git a/pkg/portage/repository/deprecated.go b/pkg/portage/repository/deprecated.go
index 4c642b7..f9348d6 100644
--- a/pkg/portage/repository/deprecated.go
+++ b/pkg/portage/repository/deprecated.go
@@ -70,7 +70,11 @@ func parsePackagesDeprecated(entry string) {
var reason string
packageLine, packageLines = packageLines[0], packageLines[1:]
for strings.HasPrefix(packageLine, "#") {
- reason = reason + " " + strings.Replace(packageLine, "# ", "", 1)
+ if packageLine == "#" {
+ reason += "\n"
+ } else {
+ reason = reason + " " + strings.TrimPrefix(packageLine, "# ")
+ }
packageLine, packageLines = packageLines[0], packageLines[1:]
}
diff --git a/pkg/portage/repository/mask.go b/pkg/portage/repository/mask.go
index 1b70c64..22715f2 100644
--- a/pkg/portage/repository/mask.go
+++ b/pkg/portage/repository/mask.go
@@ -113,7 +113,11 @@ func parsePackageMask(packageMask string) {
var reason string
packageMaskLine, packageMaskLines = packageMaskLines[0], packageMaskLines[1:]
for strings.HasPrefix(packageMaskLine, "#") {
- reason = reason + " " + strings.Replace(packageMaskLine, "# ", "", 1)
+ if packageMaskLine == "#" {
+ reason += "\n"
+ } else {
+ reason = reason + " " + strings.TrimPrefix(packageMaskLine, "# ")
+ }
packageMaskLine, packageMaskLines = packageMaskLines[0], packageMaskLines[1:]
}