Skip to content

insert_text() treats all content as single paragraph, limiting formatting flexibility #1

@matrayu

Description

@matrayu

Problem

The insert_text() function currently treats all inserted content as a single continuous paragraph, preventing granular style application.

Current Behavior

insert_text(
    text_frame_index=0, 
    text="CHAPTER 1\n\nNew York Harbor\n\nIn the beginning...",
    page_index=0
)

Result:

  • ✅ All content inserted successfully
  • ❌ All content treated as one paragraph
  • ❌ Cannot apply different styles to different sections
  • ❌ Chapter title gets same formatting as body text
  • ❌ Scene breaks ("* * *") cannot be centered separately

Desired Behavior

Should preserve paragraph structure from the text input:

  • Paragraph 1: "CHAPTER 1" → Apply "Chapter Title" style
  • Paragraph 2: "New York Harbor" → Apply "Location" style
  • Paragraph 3: "In the beginning..." → Apply "Body Text" style

Workaround

Use insert_formatted_paragraphs() instead:

insert_formatted_paragraphs(
    text_frame_index=0,
    page_index=0,
    paragraphs=[
        {"text": "CHAPTER 1", "style": "Chapter Title Large"},
        {"text": "New York Harbor", "style": "Chapter Location Italic"},
        {"text": "In the beginning...", "style": "Body First Drop"}
    ]
)

Limitation of workaround: Requires pre-parsing text into paragraphs with style assignments.

Proposed Solutions

Option 1: Parse newlines as paragraph breaks in insert_text()

Modify insert_text() to:

  1. Split text by \n\n (double newlines)
  2. Create actual InDesign paragraphs for each section
  3. Allow subsequent apply_paragraph_style() calls to target specific paragraphs

Option 2: Add optional paragraph style mapping parameter

insert_text(
    text_frame_index=0,
    text="CHAPTER 1\n\nNew York\n\nIn the beginning...",
    paragraph_styles=["Chapter Title", "Location", "Body Text"]
)

Option 3: Document current behavior clearly

Update tool documentation to clarify:

  • insert_text() is for uniform formatting only
  • Use insert_formatted_paragraphs() for mixed formatting
  • Provide clear examples of when to use each

Impact

Severity: Medium
Workaround exists: Yes (insert_formatted_paragraphs())
Affects: Users expecting paragraph-aware formatting from plain text insertion

Files Involved

  • adobe_mcp/indesign/server.py - insert_text() tool
  • uxp-plugins/indesign/commands/text.js - insertText handler
  • Documentation to update if behavior is intentional

Related

  • Tool added in commit f188798
  • insert_formatted_paragraphs() added in commit 8ea7aed as solution

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions