Skip to content

feat(indesign-export): platform + post types settings, en-dash fix#463

Open
miguelpeixe wants to merge 6 commits into
mainfrom
fix/nppm-2813-indesign-export-platform-encoding
Open

feat(indesign-export): platform + post types settings, en-dash fix#463
miguelpeixe wants to merge 6 commits into
mainfrom
fix/nppm-2813-indesign-export-platform-encoding

Conversation

@miguelpeixe

Copy link
Copy Markdown
Member

Moved from Automattic/newspack-plugin#4725 into the monorepo (plugins/newspack-plugin/).

All Submissions:

Changes proposed in this Pull Request:

Fixes two bugs in the InDesign Tagged Text export and adds two site-level settings under Newspack > Settings > Print > Adobe InDesign.

  • Platform mismatch on macOS. The exporter hardcoded the <ASCII-WIN> header on every file, which caused InDesign on Mac to render the tagged-text markup literally instead of interpreting it. A new "Header platform" setting controls the header:

    • Auto-detect (per export) — default. Sniffs the User-Agent of whoever clicks Export and emits the matching <ASCII-MAC> / <ASCII-WIN> header.
    • Mac — always emit <ASCII-MAC>.
    • Windows — always emit <ASCII-WIN>.

    A newspack_indesign_export_platform filter is available for code-level overrides.

  • En-dash silently converted to em-dash. Every en-dash (, U+2013) in post content was being rewritten to an em-dash (U+2014). Each dash now maps to its own code point.

  • Choose which post types are exportable. A new "Available post types" setting lets admins pick which post types show the export action on their list screens. The picker lists every public post type with an admin UI (excluding attachments), so plugins that register custom post types — events, classifieds, etc. — can opt in without code. The default stays at post to preserve current behavior. The existing newspack_indesign_export_supported_post_types filter still runs after the setting and can extend or restrict the result.

image

Closes NPPM-2813.

How to test the changes in this Pull Request:

  1. Enable the optional InDesign Export module: visit Newspack > Settings > Print > Adobe InDesign and toggle "Enable InDesign Export" on. New "Header platform" and "Available post types" sections appear.

Header platform

  1. Confirm the platform dropdown defaults to Auto-detect (per export).
  2. Create a post containing an en-dash, an em-dash, and a double-hyphen (e.g. before – after, before — after, before -- after).
  3. From the posts list, choose "Export as Adobe InDesign". Open the downloaded .txt. With Auto-detect, the first line should be <ASCII-MAC> on macOS or <ASCII-WIN> on Windows. The body should contain before <0x2013> after for the en-dash and before <0x2014> after for the em-dash and the double-hyphen.
  4. Switch the setting to Mac, re-export, and confirm the first line is <ASCII-MAC> regardless of your OS. Repeat with Windows and confirm <ASCII-WIN>.

Available post types

  1. Confirm the "Available post types" section lists every public post type with an admin UI on your site (post, page, and any active CPTs). Attachments should not appear.
  2. Confirm only Posts is checked by default (preserves prior behavior).
  3. Visit the Pages list — the "Export as Adobe InDesign" bulk action and row action should be absent.
  4. Check the Pages box. Reload the Pages list — the export actions should now appear. Export a page and confirm the file content matches the post output format.
  5. Confirm both settings persist across page reloads.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

@miguelpeixe miguelpeixe self-assigned this Jun 30, 2026
@miguelpeixe miguelpeixe marked this pull request as ready for review June 30, 2026 14:19
@miguelpeixe miguelpeixe requested a review from a team as a code owner June 30, 2026 14:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new configuration and fixes for the Newspack InDesign Tagged Text export, integrating platform header selection and exportable post type selection into the Newspack Settings “Print” tab, and correcting dash conversion behavior.

Changes:

  • Added site-level settings for InDesign export header platform (auto/mac/win) and which post types expose export actions.
  • Fixed en-dash conversion so maps to <0x2013> (and em-dash remains <0x2014>).
  • Added/expanded PHPUnit coverage for platform resolution, post type settings, and Print settings REST API behavior.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
plugins/newspack-plugin/tests/unit-tests/indesign-exporter/indesign-exporter.php Adds unit tests for platform headers, dash conversion, and post type settings logic.
plugins/newspack-plugin/tests/unit-tests/indesign-exporter/class-test-print-section.php New unit tests for Print settings REST read/update behavior and validation.
plugins/newspack-plugin/src/wizards/newspack/views/settings/types.d.ts Extends Print settings TS types to include InDesign platform and post type options.
plugins/newspack-plugin/src/wizards/newspack/views/settings/print/index.tsx Adds UI controls for “Header platform” and “Available post types” under Print settings.
plugins/newspack-plugin/includes/wizards/newspack/class-print-section.php Extends Print settings REST endpoints to read/write the new InDesign settings.
plugins/newspack-plugin/includes/optional-modules/indesign-export/class-indesign-converter.php Selects <ASCII-MAC> vs <ASCII-WIN> header based on option; fixes en-dash mapping.
plugins/newspack-plugin/includes/optional-modules/class-indesign-exporter.php Implements platform resolution (including UA sniffing), post type settings, and gating by enabled types.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants