Skip to content

Jesus words in red: red stops at the first bracketed [phrase] and the following space is lost (AMP) #3706

Description

@josephomills

Before submitting

  • I searched existing open and closed issues.
  • I reproduced this on the latest available version.

Describe the bug

With "Jesus words in red" enabled, verses whose red-letter text contains a bracketed phrase only turn red up to the end of the first bracket; the rest of the verse stays in the normal colour, and the space after the bracket is lost ("admired]are"). The Amplified Bible is hit on nearly every red-letter verse because its amplifications are written as [...], which the JSON Bible format renders as <span class="uncertain">.

Cause, in src/frontend/components/drawer/bible/scripture.ts (getScriptureSlidesNew): the HTML from json-bible is converted back into !{ }! markers with

text = text.replace(/<span style="color:red;" ?>(.*?)<\/span>/g, "!{$1}!")

(and the <span class="wj"> / <red> variants). The lazy (.*?) stops at the first </span>, which for a bracketed phrase is the inner span's closing tag, so the closing marker lands after the first bracket. For AMP Matthew 5:3 the runs become:

[red]   "Blessed <span class=uncertain">[spiritually prosperous, happy, to be admired]
[plain] are the poor in spirit <span class=uncertain>[those devoid of ...]</span>, for theirs is the kingdom of heaven ...

The leading space of the second run is then removed by sanitizeVerseText(...).trim(), which is where "admired]are" comes from. With the toggle off the same cut leaves that first <span class="uncertain"> unclosed in the output HTML. The drawer verse list is unaffected because it renders the json-bible HTML directly, so the drawer shows the whole verse red while the output does not.

Steps to reproduce

  1. Import the Amplified Bible (AMP) as a JSON bible, or any bible whose !{ }! text contains [...].
  2. Drawer → Scripture → scripture settings → turn on "Jesus words in red".
  3. Show Matthew 5:3: only "Blessed [spiritually prosperous, happy, to be admired]" is red, "are the poor in spirit …" is white. John 3:16: only "For God so [greatly]" is red.
  4. Compare with KJV John 3:16, which has no brackets and turns fully red.

Expected behavior

The whole !{ }! range is red, bracketed text keeps its own styling inside it, and the spacing between runs is preserved, matching what the drawer list shows.

Screenshots, logs, or files

Image

Output of AMP Matthew 5:3 with the toggle on: red stops after the first bracket, the drawer list below shows the full verse red.

Operating System

macOS

FreeShow version

1.6.5

Additional context

The regex cannot handle nested spans. Two ways out: split on the JSON !{ }! markers before parseMarkdown runs (then parse each segment), or match the red span with a nesting-aware scan instead of (.*?)<\/span>. Trimming each segment separately also drops the inter-run space, so the split should keep boundary spaces.

Possibly related: the legacy path (getScriptureSlides, used by templates without {scripture_…} values) runs removeTags(formatBibleText(...)) in red mode, which strips headings and italics from the output, while the non-red branch deliberately keeps custom HTML.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions