-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Service mark * Copyrights * Swap params order * Update dependencies * Update version
- Loading branch information
Showing
27 changed files
with
326 additions
and
242 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import {addSpaceBeforeSymbol} from "../whitespace/spaces"; | ||
import {addNbspAfterSymbol, | ||
replaceSpacesWithNbspAfterSymbol} from "../whitespace/nbsp"; | ||
|
||
|
||
/** | ||
* Replaces occurrences of a copyright indication in a string followed by a year. | ||
* | ||
* Example: Company (c) 2017 -> Company © 2017 | ||
* | ||
* @param {string} string - The input string where marks will be replaced. | ||
* @param {string} copyrightLetter - The pattern for the copyright (e.g., “p” for sound recording copyright). | ||
* @param {string} copyrightSign - The symbol to replace the pattern with (e.g., “©” for copyright). | ||
* @param {Object} locale - An object w/ locale-specific symbols. | ||
* @returns {string} - The string with the specified copyrights replaced. | ||
*/ | ||
export function replaceCopyright(string, copyrightLetter, copyrightSign, locale) { | ||
return string.replace( | ||
new RegExp( | ||
"(\\(" + copyrightLetter + "\\))" | ||
+ "([" + locale.spaces + "]*)" | ||
+ "(" + locale.cardinalNumber + ")", | ||
"gi" | ||
), | ||
copyrightSign + "$2$3" | ||
); | ||
} | ||
|
||
|
||
|
||
/** | ||
* Consolidates spaces around copyright sign | ||
* | ||
* @param {string} string - The input string where marks will be replaced. | ||
* @param {string} copyrightSign - The sign of choice, either © or ℗ | ||
* @param {Object} locale - An object w/ locale-specific symbols. | ||
* @returns {string} - The string with the consolidated spaces around the copyright sign | ||
*/ | ||
export function consolidateSpaces(string, copyrightSign, locale) { | ||
string = addSpaceBeforeSymbol(string, copyrightSign, locale); | ||
string = addNbspAfterSymbol(string, copyrightSign, locale); | ||
string = replaceSpacesWithNbspAfterSymbol(string, copyrightSign, locale); | ||
return string; | ||
} | ||
|
||
|
||
/** | ||
* Fixes occurrences of copyright (©), and sound recording copyright (℗) in a given string. | ||
* | ||
* @param {string} string - The input string to be fixed. | ||
* @param {Object} locale - An object w/ locale-specific symbols | ||
* @returns {string} - The string with marks replaced. | ||
*/ | ||
export function fixCopyrights(string, locale) { | ||
string = replaceCopyright(string, "c", locale.copyright, locale); | ||
string = consolidateSpaces(string, locale.copyright, locale); | ||
string = replaceCopyright(string, "p", locale.soundRecordingCopyright, locale); | ||
string = consolidateSpaces(string, locale.soundRecordingCopyright, locale); | ||
return string; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Replaces occurrences of a specific mark in a string. | ||
* | ||
* Example: Company (tm) -> Company™ | ||
* | ||
* @param {string} string - The input string where marks will be replaced. | ||
* @param {string} markPattern - The pattern for the mark (e.g., “tm” for trademark). | ||
* @param {string} replacementMark - The symbol to replace the pattern with (e.g., “™” for trademark). | ||
* @param {Object} locale - An object w/ locale-specific symbols. | ||
* @returns {string} - The string with the specified marks replaced. | ||
*/ | ||
export function replaceMark(string, markPattern, replacementMark, locale) { | ||
return string.replace( | ||
new RegExp( | ||
"([^0-9]|^)" | ||
+ "([" + locale.spaces + "]*)" | ||
+ "(\\(" + markPattern + "\\)|" + replacementMark + ")", | ||
"gi" | ||
), | ||
"$1" + replacementMark | ||
); | ||
} | ||
|
||
|
||
|
||
/** | ||
* Fixes occurrences of registered trademark (®), service mark (℠) and trademark (™) in a given string. | ||
* | ||
* @param {string} string - The input string to be fixed. | ||
* @param {Object} locale - An object w/ locale-specific symbols | ||
* @returns {string} - The string with marks replaced. | ||
*/ | ||
export function fixMarks(string, locale) { | ||
|
||
string = replaceMark(string, "r", locale.registeredTrademark, locale); | ||
string = replaceMark(string, "sm", locale.serviceMark, locale); | ||
string = replaceMark(string, "tm", locale.trademark, locale); | ||
|
||
return string; | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.