- Extracts the LLM API call retry logic into a private `generateContentWithRetry` method for improved readability and separation of concerns.
- Defines a `maxRetries` constant for the retry limit.
- Moves the `htmlEscape` function from `templates.go` to `funcs.go` to centralize all template functions.
- Renames `nl2br` to `textToHTML` for clarity.
- Updates the templates to use the new function name.
Adds a template function to convert newline characters in the digest summary to HTML `<br>` tags, preserving the intended formatting.
The new `nl2br` function also ensures the summary content is HTML-escaped to prevent XSS vulnerabilities.
Implements a retry mechanism for when the LLM service returns a 503 "overloaded" error.
The changes include:
- Retrying the API call up to two times (three attempts total).
- A backoff delay that increases with each retry.
- Specific error checking for `*genai.APIError` with a 503 status code and "overloaded" message.
- Logging of LLM API errors to aid in future debugging.