summaryrefslogtreecommitdiff
path: root/node_modules/typographic-quotes/index.es5.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/typographic-quotes/index.es5.js')
-rw-r--r--node_modules/typographic-quotes/index.es5.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/node_modules/typographic-quotes/index.es5.js b/node_modules/typographic-quotes/index.es5.js
new file mode 100644
index 0000000..a338ae9
--- /dev/null
+++ b/node_modules/typographic-quotes/index.es5.js
@@ -0,0 +1,50 @@
+'use strict';
+
+Object.defineProperty(exports, '__esModule', {
+ value: true
+});
+exports['default'] = typographicQuotes;
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+var _typographicQuotesL10nDb = require('typographic-quotes-l10n-db');
+
+var _typographicQuotesL10nDb2 = _interopRequireDefault(_typographicQuotesL10nDb);
+
+function typographicQuotes() {
+ var input = arguments.length <= 0 || arguments[0] === undefined ? '' : arguments[0];
+
+ var _ref = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
+
+ var locale = _ref.locale;
+
+ if (Object.keys(_typographicQuotesL10nDb2['default']).indexOf(locale) === -1) {
+ return input;
+ }
+ var localeQuotes = _typographicQuotesL10nDb2['default'][locale];
+ var separator = '';
+
+ var pattern = /(^|\s)(?:"(.*?)"|'(.*?)')(\s|$|\.|,|\?|!)/gim;
+ var handleQuotes = function handleQuotes(quotes, cb) {
+ return function (match) {
+ var before = arguments.length <= 1 || arguments[1] === undefined ? '' : arguments[1];
+ var part1 = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
+ var part2 = arguments.length <= 3 || arguments[3] === undefined ? '' : arguments[3];
+ var after = arguments.length <= 4 || arguments[4] === undefined ? '' : arguments[4];
+
+ var text = part1 + part2;
+ if (cb) {
+ text = text.replace(pattern, cb);
+ }
+ if (locale === 'fr') {
+ separator = ' ';
+ }
+ return '' + before + quotes[0] + separator + text + separator + quotes[1] + after;
+ };
+ };
+
+ return input.replace(pattern, handleQuotes(localeQuotes.slice(0, 2), handleQuotes(localeQuotes.slice(2, 4))));
+}
+
+module.exports = exports['default'];
+