seconv: --multiple-replace accepts GUI-exported .template JSON and .csv#12546
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12544.
Problem
In SE4 the CLI (
SubtitleEdit.exe /convert) shared the GUI'sSettings.xml, so multiple-replace rules were automatically the same in both. SE5 broke that link:seconv --multiple-replacereads only the legacyMultipleSearchAndReplaceGroupsXML, 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. (--settingscan't help either: the rules live in the UI settings tree, not libseConfiguration, so that path never carries them.)Fix
MultipleReplaceLoadernow 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:CategoryImportExportItemshape (categories[].rules[].{find, replaceWith, description, isActive, type}), read camelCase-insensitively.Category,Find,ReplaceWith,Description,Active,Type) with RFC 4180 quoting; the parser is ported verbatim from the UI'sCsvImporterso round-trips are guaranteed.The UI's
MultipleReplaceTypenames map to the XMLSearchTypethe apply loop expects (CaseInsensitive→Normal;CaseSensitive/RegularExpressionby name). Only active rules are applied. Existing XML behavior is untouched.Docs
docs/reference/command-line.mdnow 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
CaseInsensitive/CaseSensitive/RegularExpression, an inactive rule that must be ignored, a case-sensitive non-match, and extension-less content sniffing..xml,.csvand.templateall yield identical SRT output.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