diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index fbd2195..9341dce 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -37,8 +37,6 @@ jobs: - name: Docker Build and Stage run: | - printf "TELEGRAM_ID: \"$TELEGRAM_ID\"\nADMIN_ID: \"$ADMIN_ID\"\nGCLOUD_PROJECT_ID: \"$GCLOUD_PROJECT_ID\"\n" >> secrets.yaml - cat secrets.yaml docker build --build-arg GCLOUD_PROJECT_ID=$GCLOUD_PROJECT_ID -f Dockerfile -t $GCLOUD_REGION-docker.pkg.dev/$GCLOUD_PROJECT_ID/$ARTIFACT_ID/root:latest . docker push $GCLOUD_REGION-docker.pkg.dev/$GCLOUD_PROJECT_ID/$ARTIFACT_ID/root:latest diff --git a/Dockerfile b/Dockerfile index a91057b..678b4da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,6 @@ FROM scratch AS runner ARG GCLOUD_PROJECT_ID ENV GCLOUD_PROJECT_ID=$GCLOUD_PROJECT_ID -COPY --from=builder /go/src/app/secrets.yaml /go/bin/secrets.yaml COPY --from=builder /go/src/app/resource/* /go/bin/ COPY --from=builder /go/bin/main /go/bin/main COPY --from=certificates /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt diff --git a/pkg/app/ask_test.go b/pkg/app/ask_test.go index 7630c4b..f1858fd 100644 --- a/pkg/app/ask_test.go +++ b/pkg/app/ask_test.go @@ -90,7 +90,7 @@ func TestGetBibleAsk(t *testing.T) { env = GetBibleAsk(env) // Expect fallback to search - expected := "Found 1 results for 'Question':\n- John 3:16\n" + expected := "Found 1 results for 'Question':\n- John 3:16\n" if env.Res.Message != expected { t.Errorf("Expected search result message, got: %s", env.Res.Message) } diff --git a/pkg/app/passage.go b/pkg/app/passage.go index c3065db..963c6f1 100644 --- a/pkg/app/passage.go +++ b/pkg/app/passage.go @@ -42,6 +42,22 @@ func GetReference(doc *html.Node) string { } +func isNextSiblingBr(node *html.Node) bool { + for next := node.NextSibling; next != nil; next = next.NextSibling { + if next.Type == html.TextNode { + if len(strings.TrimSpace(next.Data)) == 0 { + continue + } + return false + } + if next.Type == html.ElementNode && next.Data == "br" { + return true + } + return false + } + return false +} + func ParseNodesForPassage(node *html.Node) string { var text string var parts []string @@ -53,7 +69,7 @@ func ParseNodesForPassage(node *html.Node) string { case "span": childText := ParseNodesForPassage(child) parts = append(parts, childText) - if len(strings.TrimSpace(childText)) > 0 { + if len(strings.TrimSpace(childText)) > 0 && !isNextSiblingBr(child) { parts = append(parts, "\n") } case "sup": diff --git a/pkg/app/passage_test.go b/pkg/app/passage_test.go index 8496fce..13b8662 100644 --- a/pkg/app/passage_test.go +++ b/pkg/app/passage_test.go @@ -141,12 +141,20 @@ func TestParsePassageFromHtml(t *testing.T) { t.Run("HTML with spans", func(t *testing.T) { html := `
Line 1.
Line 2.
Line 1
Line 2
Line 1.
Line 2.