Skip to content

seconv: --multiple-replace accepts GUI-exported .template JSON and .csv#12546

Merged
niksedk merged 1 commit into
mainfrom
feat/seconv-multiple-replace-csv-json
Jul 16, 2026
Merged

seconv: --multiple-replace accepts GUI-exported .template JSON and .csv#12546
niksedk merged 1 commit into
mainfrom
feat/seconv-multiple-replace-csv-json

Conversation

@niksedk

@niksedk niksedk commented Jul 16, 2026

Copy link
Copy Markdown
Member

Fixes #12544.

Problem

In SE4 the CLI (SubtitleEdit.exe /convert) shared the GUI's Settings.xml, so multiple-replace rules were automatically the same in both. SE5 broke that link: seconv --multiple-replace reads only the legacy MultipleSearchAndReplaceGroups XML, but the SE5 GUI (Tools → Multiple replace → export) writes .template (JSON) or .csv — never that XML. So there was no way to use GUI rules in seconv, which is exactly the dead end the reporter hit. (--settings can't help either: the rules live in the UI settings tree, not libse Configuration, so that path never carries them.)

Fix

MultipleReplaceLoader now detects the format — by extension, then by sniffing the first non-whitespace char (< = XML, { = JSON, else CSV) — and loads all three into the same rule list:

  • XML — unchanged.
  • JSON — the GUI's CategoryImportExportItem shape (categories[].rules[].{find, replaceWith, description, isActive, type}), read camelCase-insensitively.
  • CSV — the GUI's exact columns (Category,Find,ReplaceWith,Description,Active,Type) with RFC 4180 quoting; the parser is ported verbatim from the UI's CsvImporter so round-trips are guaranteed.

The UI's MultipleReplaceType names map to the XML SearchType the apply loop expects (CaseInsensitiveNormal; CaseSensitive/RegularExpression by name). Only active rules are applied. Existing XML behavior is untouched.

Docs

docs/reference/command-line.md now leads with the GUI-export workflow (export as .csv/.template, pass straight to --multiple-replace), shows the CSV shape, and keeps the legacy XML sample.

Verified

  • 4 unit tests: XML, CSV and JSON produce byte-identical replacements — covering CaseInsensitive/CaseSensitive/RegularExpression, an inactive rule that must be ignored, a case-sensitive non-match, and extension-less content sniffing.
  • seconv end-to-end: the same rules as .xml, .csv and .template all yield identical SRT output.
  • All 237 seconv tests pass.

Change-log updated (also folds in the other rc5 entries merged since the last changelog update: EBU-TT-D, the F10 fix, the culture-parse fix, and the perf rounds).

🤖 Generated with Claude Code

…sv (#12544)

In SE4 the CLI shared the GUI's Settings.xml, so multiple-replace rules were
automatically the same. SE5 broke that: --multiple-replace read only the
legacy MultipleSearchAndReplaceGroups XML, but the GUI (Tools > Multiple
replace > export) now writes .template (JSON) or .csv, never that XML - so
there was no way to feed GUI rules to seconv.

MultipleReplaceLoader now detects the format (by extension, then by sniffing
the first non-whitespace char) and loads all three into the same rule list:
- XML: unchanged (SE4 MultipleSearchAndReplaceGroups).
- JSON: the GUI's CategoryImportExportItem shape (categories -> rules with
  find/replaceWith/description/isActive/type), read camelCase-insensitively.
- CSV: the GUI's exact columns (Category,Find,ReplaceWith,Description,Active,
  Type), RFC 4180 quoting - the parser is ported from the UI's CsvImporter.
The UI's MultipleReplaceType names map to the XML SearchType the apply loop
uses (CaseInsensitive -> Normal; others by name); only active rules apply.

Docs (command-line reference) updated to lead with the GUI-export workflow
and show the CSV shape. --settings is deliberately not touched: the rules
live in the UI settings tree, not libse Configuration, so that path can't
carry them - the export file is the right interchange.

Verified: 4 unit tests proving XML/CSV/JSON produce byte-identical
replacements (incl. an inactive rule and a case-sensitive non-match), plus
a seconv end-to-end run where all three formats give identical SRT output.
All 237 seconv tests pass.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@niksedk
niksedk merged commit d492b7f into main Jul 16, 2026
1 of 3 checks passed
@niksedk
niksedk deleted the feat/seconv-multiple-replace-csv-json branch July 16, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using seconv with --multiple-replace

1 participant