Insert the regenerated Reader Intelligence Guide HTML immediately after
the Executive Brief section so the rendered article body matches the
documented order (Executive Brief → Reader Intelligence Guide → Key
Takeaways → deep sections). The Executive Brief section ends where the
next H2 begins; we splice at that boundary. When the brief is absent
(sparse runs) we fall back to prepending so the guide still appears
at the top of the body.
Implementation uses indexOf rather than a regex so the splice point
is deterministic and immune to polynomial-regex backtracking on
pathological input.
Parameters
bodyHtml: string
Rendered article body
guideHtml: string
Reader Intelligence Guide HTML fragment
Returns string
Body HTML with the guide spliced after the Executive Brief
Insert the regenerated Reader Intelligence Guide HTML immediately after the Executive Brief section so the rendered article body matches the documented order (Executive Brief → Reader Intelligence Guide → Key Takeaways → deep sections). The Executive Brief section ends where the next H2 begins; we splice at that boundary. When the brief is absent (sparse runs) we fall back to prepending so the guide still appears at the top of the body.
Implementation uses
indexOfrather than a regex so the splice point is deterministic and immune to polynomial-regex backtracking on pathological input.