From 813493ffa7d79c015d5aa27dea02458e6a78e8c4 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Fri, 29 May 2026 08:48:51 +0700 Subject: [PATCH] add format string --- internal/modules/formatter/interface.go | 1 + internal/modules/formatter/service.go | 8 ++++++++ internal/services/story_service/service.go | 8 ++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/internal/modules/formatter/interface.go b/internal/modules/formatter/interface.go index d5e99fb..3fd0ec0 100644 --- a/internal/modules/formatter/interface.go +++ b/internal/modules/formatter/interface.go @@ -2,4 +2,5 @@ package formatter type IFormatter interface { FormatText(text string) string + FormatString(text string) string } diff --git a/internal/modules/formatter/service.go b/internal/modules/formatter/service.go index 4c75f8e..2639a77 100644 --- a/internal/modules/formatter/service.go +++ b/internal/modules/formatter/service.go @@ -40,3 +40,11 @@ func (s *service) FormatText(text string) string { } return res.String() } + +func (s *service) FormatString(text string) string { + l := strings.TrimSpace(text) + if strings.HasPrefix(l, "--") { + l = strings.Replace(l, "--", "—", 1) + } + return l +} diff --git a/internal/services/story_service/service.go b/internal/services/story_service/service.go index f59c15b..751f255 100644 --- a/internal/services/story_service/service.go +++ b/internal/services/story_service/service.go @@ -175,7 +175,7 @@ func (s *StoryService) updatePlace(ctx context.Context, code string, node *Graph if s.story.Places[i].Code == code { s.story.Places[i] = models.NewPlace( node.Code, - node.Name, + s.formatter.FormatString(node.Name), s.formatter.FormatText(node.Text), models.WithPlaceImage(node.Image), models.WithPlaceApplication(s.getApplications(node)...), @@ -189,7 +189,7 @@ func (s *StoryService) updatePlace(ctx context.Context, code string, node *Graph if s.story.Places[i].Code == node.Code { s.story.Places[i] = models.NewPlace( code, - node.Name, + s.formatter.FormatString(node.Name), s.formatter.FormatText(node.Text), models.WithPlaceImage(node.Image), models.WithPlaceApplication(s.getApplications(node)...), @@ -208,7 +208,7 @@ func (s *StoryService) getApplications(node *GraphNode) []*models.Application { nodeApplications = append( nodeApplications, &models.Application{ - Name: application.Name, + Name: s.formatter.FormatString(application.Name), }, ) } @@ -222,7 +222,7 @@ func (s *StoryService) getDoors(node *GraphNode) []*models.Door { nodeDoors, &models.Door{ Code: door.Code, - Name: door.Name, + Name: s.formatter.FormatString(door.Name), Show: door.Show, }, )