Skip to content

[Enhancement] Prevent duplicate JournalEntry page headings when title.show is enabled #177

Description

@Daxiongmao87

Summary

When Simulacrum creates a text page inside a Foundry JournalEntry, it may set the embedded page's name, enable title.show, and also begin text.content with an identical <h1>.

Foundry correctly renders page.name as an H1 when title.show is enabled, then renders the authored H1 inside the page content. The result is a duplicated visible heading such as:

Character Spotlights
Character Spotlights

This is not a Foundry rendering bug. It is a JournalEntry generation-guidance issue: the agent/tooling does not make the interaction between page.name, page.title.show, and the first heading in page.text.content sufficiently clear.

Observed output

Example document data:

{
  "name": "Character Spotlights",
  "type": "text",
  "title": {
    "show": true,
    "level": 1
  },
  "text": {
    "format": 1,
    "content": "<h1>Character Spotlights</h1><ul>...</ul>"
  }
}

Foundry renders this as:

<article class="journal-entry-page text level1 page">
  <header class="journal-page-header">
    <h1>Character Spotlights</h1>
  </header>
  <section class="journal-page-content">
    <h1 data-anchor="character-spotlights$1">Character Spotlights</h1>
    <ul>...</ul>
  </section>
</article>

Expected behavior

JournalEntry creation guidance should direct the model to use one of these two patterns:

Foundry-rendered page title

{
  "name": "Character Spotlights",
  "title": { "show": true, "level": 1 },
  "text": {
    "content": "<ul>...</ul><h2>Mission Pressure</h2><p>...</p>"
  }
}

When title.show is enabled, the content should begin with body text, a paragraph, a list, or an H2 subsection—not an H1 identical to page.name.

Authored content title

{
  "name": "Character Spotlights",
  "title": { "show": false, "level": 1 },
  "text": {
    "content": "<h1>Character Spotlights</h1><ul>...</ul>"
  }
}

If the HTML contains its own primary H1, the Foundry page title should be hidden.

Why this belongs in Simulacrum

Foundry is rendering both supplied headings as instructed. Simulacrum should understand or communicate the presentation semantics of embedded JournalEntry pages so generated journals do not contain redundant headings by default.

The closest related issue is #143, which concerns JournalEntry page validation recovery and stronger create_document guidance. This issue is narrower and concerns valid-but-visually-incorrect page generation rather than schema validation failure.

Suggested implementation areas

Based on the implementation references in #143, likely locations include:

  • scripts/tools/document-create.js
    • Improve the JournalEntry-specific page example and creation guidance.
  • scripts/utils/validation-errors.js
    • Optionally provide a non-blocking warning or corrective hint.
  • JournalEntry embedded-page schema descriptions or agent tool instructions.
  • Equivalent handling for update_document, since replacement or insertion of pages can introduce the same duplication.

Proposed guidance text

When page.title.show is true, Foundry renders page.name as the page heading. Do not begin page.text.content with an identical <h1>. Begin with body content or <h2> subsections instead. If the HTML must contain its own primary heading, set page.title.show to false.

Optional detection

A non-blocking warning could detect the common case:

if (
  page.type === "text" &&
  page.title?.show !== false &&
  normalize(firstHeading(page.text?.content)) === normalize(page.name)
) {
  warn(
    "Foundry will render page.name as a heading; the identical opening H1 in text.content will duplicate the visible page title."
  );
}

A warning is preferable to silently stripping or rewriting authored HTML, since duplicate headings could occasionally be intentional.

Acceptance criteria

  • JournalEntry creation guidance explains how page.name, title.show, and HTML headings interact.
  • The minimal JournalEntry example does not combine title.show: true with an identical opening H1.
  • The model is guided toward either:
    • title.show: true with content beginning below H1 level, or
    • title.show: false with an authored H1.
  • The same guidance applies when inserting or replacing pages through update_document.
  • Optionally, creation/update tools provide a non-blocking warning for an identical leading H1.
  • Add a regression test using the rendered HTML structure above.
  • Cross-reference [Tool] Improve JournalEntry page validation recovery and guidance in create_document #143 as related JournalEntry guidance work.

Reproduction

  1. Ask Simulacrum to create a multi-page JournalEntry.
  2. Give each text page a name and title.show: true.
  3. Generate page HTML beginning with <h1> containing the same text as the page name.
  4. Open the JournalEntry in Foundry.
  5. Observe two consecutive identical H1 headings on each affected page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions