Context
We currently working on some code that's generating names for reused references in VE automatically. With the new code the names will come from potentially random user input. Therefore we should make sure that some basic rules apply to what can be part of these names and what should be stripped / normalized.
Task
Add the following rules to normalize the output of the auto generation:
- Remove leading and trailing whitespaces
- Normalize multiple whitespaces to only one simple space
- Remove or replace all of the following characters: < > “ ’ / \ =
- Only whitespace or empty string → fallback
Only numbers → prefix with “:”
- Tests
Normalization / Fallback strategy increment 1
- Is citation type?
- Yes: Has override?
- Yes: Use Citation title override and normalize -> If empty after normalization, fallback to next line
- No: Use Citation title default and normalize -> If empty after normalization, fallback to next line
- No: Is there a override for the default title?
- Yes: Use default title override and normalize -> If empty after normalization, fallback to next line
- No: Use default title and normalize -> If empty after normalization, fallback to next line
- Yes: Has override?
- Use : as prefix