Pad slashes in names with spaces
Description, Motivation & Context
Replaces #874, as requested by @matkoniecz in https://github.com/openstreetmap/id-tagging-schema/pull/874#issuecomment-3568362692.
Related issues
–
Links and data
Relevant OSM Wiki links: – Relevant tag usage stats: –
Checklist and Test-Documentation Template
Read on to get your PR merged faster…
Follow these steps to test your PR yourself and make it a lot easier and faster for maintainers to check and approve it.
This is how it works:
-
After you submit your PR, the system will create a preview and comment on your PR:
🍱 Your pull request preview is ready. If this is your first contribution to this project, the preview will not happen right away but requires a click from one of the project members. We will do this ASAP.
-
Once the preview is ready, use it to test your changes.
-
Now copy the snippet below into a new comment and fill out the blanks.
-
Now your PR is ready to be reviewed.
## Test-Documentation
### Preview links & Sidebar Screenshots
<!-- Use the preview to find examples, select the feature in question and **copy this link here**.
Find examples of nodes/areas. Find examples with a lot of tags or very few tags. – Whatever helps to test this thoroughly.
Add relevant **screenshots** of the sidebar of those examples. -->
<!-- FYI: What we will check:
- Is the [icon](https://github.com/ideditor/schema-builder/blob/main/ICONS.md) well chosen.
- Are the fields well-structured and have good labels.
- Do the dropdowns (etc.) work well and show helpful data. -->
### Search
<!-- **Test the search** of your preset and share relevant **screenshots** here.
- Test the preset name as search terms.
- Also test the preset terms and aliases as search terms (if present). -->
### Info-`i`
<!-- **Test the info-i** for your fields and preset and share relevant **screenshots** here.
The info needs to help mappers understand the preset and when to use it.
[Learn more…](https://github.com/openstreetmap/id-tagging-schema/blob/main/CONTRIBUTING.md#info-i)
-->
### Wording
- [ ] American English
- [ ] `name`, `aliases` (if present) use Title Case
- [ ] `terms` (if present) use lower case, sorted A-Z
<!-- Learn more in https://github.com/openstreetmap/id-tagging-schema/blob/main/GUIDELINES.md#2-design-the-preset -->
For reference, this is the code used to generated these changes:
scripts/pad-slashes.js
#!/usr/bin/env zx
// NOTE: uses https://github.com/google/zx and has to be called from id-tagging-schema root directory
const presetJsonFiles = await glob('./data/presets/**/*.json', {
gitignore: true,
absolute: true,
})
/** @param {string} name */
function getPaddedSlashesString(name) {
if (name.startsWith('{') && name.endsWith('}')) {
return name
}
return name.replace(/\s*\/\s*/g, ' / ')
}
for (const file of presetJsonFiles) {
const preset = JSON.parse(fs.readFileSync(file, 'utf-8'))
const expectedName = getPaddedSlashesString(preset.name)
const expectedAliases = preset.aliases?.map(getPaddedSlashesString)
if (
expectedName === preset.name &&
(!preset.aliases ||
preset.aliases.every((alias, index) => expectedAliases[index] === alias)
)
) {
continue
}
console.log(file)
preset.name = expectedName
preset.aliases = expectedAliases
fs.writeFileSync(file, JSON.stringify(preset, null, 4) + '\n', 'utf8')
}
:bento: Your pull request preview is ready
Please use this preview to check your changes. Ideally use the test documentation template and document your test results by commenting on the PR. This will speed up the review process for everyone.
FYI, once this PR is merged, you can use the iD Editor Preview to test your changes in interaction with all other changes.
let's wait unit after the December release for this, as this would invalidate translations, and that way translators have a bit more time to re-translate the affected strings.