Story undupe
This commit is contained in:
parent
778ea957f0
commit
a954e22d3b
11
main.go
11
main.go
@ -55,6 +55,8 @@ func injectStories(table Table, path string, heisigIndex int) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seenStories := make(map[string]bool)
|
||||||
|
|
||||||
for i, row := range table {
|
for i, row := range table {
|
||||||
for _, character := range characters {
|
for _, character := range characters {
|
||||||
if character.Character != row[heisigIndex] {
|
if character.Character != row[heisigIndex] {
|
||||||
@ -63,8 +65,13 @@ func injectStories(table Table, path string, heisigIndex int) error {
|
|||||||
|
|
||||||
var stories strings.Builder
|
var stories strings.Builder
|
||||||
for _, story := range character.Stories {
|
for _, story := range character.Stories {
|
||||||
content := strings.ReplaceAll(story.Content, "\n", " ")
|
storyNoBreaks := strings.ReplaceAll(story.Content, "\n", " ")
|
||||||
stories.WriteString(wrapSpan(content, "rtk-story"))
|
if seen, _ := seenStories[storyNoBreaks]; seen {
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
|
stories.WriteString(wrapSpan(storyNoBreaks, "rtk-story"))
|
||||||
|
seenStories[storyNoBreaks] = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
row = append(row, stories.String())
|
row = append(row, stories.String())
|
||||||
|
Loading…
Reference in New Issue
Block a user