intl-messageformat-parser
Advanced tools
Comparing version 3.0.0 to 3.0.1
@@ -6,2 +6,13 @@ # Change Log | ||
## [3.0.1](https://github.com/formatjs/formatjs/compare/intl-messageformat-parser@3.0.0...intl-messageformat-parser@3.0.1) (2019-07-29) | ||
### Bug Fixes | ||
* **intl-messageformat-parser:** argStyleText can contain syntax characters and quoted string now ([#136](https://github.com/formatjs/formatjs/issues/136)) ([b39ea08](https://github.com/formatjs/formatjs/commit/b39ea08)), closes [#135](https://github.com/formatjs/formatjs/issues/135) | ||
# [3.0.0](https://github.com/formatjs/formatjs/compare/intl-messageformat-parser@2.1.3...intl-messageformat-parser@3.0.0) (2019-07-29) | ||
@@ -8,0 +19,0 @@ |
@@ -9,9 +9,2 @@ "use strict"; | ||
var types_1 = require("./types"); | ||
var ESCAPED_CHARS = { | ||
'\\': '\\\\', | ||
'\\#': '\\#', | ||
'{': '\\{', | ||
'}': '\\}' | ||
}; | ||
var ESAPE_CHARS_REGEXP = /\\#|[{}\\]/g; | ||
function printAST(ast) { | ||
@@ -39,3 +32,3 @@ var printedNodes = ast.map(function (el) { | ||
function printEscapedMessage(message) { | ||
return message.replace(ESAPE_CHARS_REGEXP, function (char) { return ESCAPED_CHARS[char]; }); | ||
return message.replace(/([{}](?:.*[{}])?)/su, "'$1'"); | ||
} | ||
@@ -61,3 +54,3 @@ function printLiteralElement(_a) { | ||
if (typeof style === 'string') { | ||
return style; | ||
return printEscapedMessage(style); | ||
} | ||
@@ -64,0 +57,0 @@ else if (style.type === 1 /* date */) { |
@@ -7,9 +7,2 @@ /* | ||
import { isLiteralElement, isSelectElement, isArgumentElement, isDateElement, isTimeElement, isNumberElement, isPluralElement, TYPE } from './types'; | ||
var ESCAPED_CHARS = { | ||
'\\': '\\\\', | ||
'\\#': '\\#', | ||
'{': '\\{', | ||
'}': '\\}' | ||
}; | ||
var ESAPE_CHARS_REGEXP = /\\#|[{}\\]/g; | ||
export function printAST(ast) { | ||
@@ -36,3 +29,3 @@ var printedNodes = ast.map(function (el) { | ||
function printEscapedMessage(message) { | ||
return message.replace(ESAPE_CHARS_REGEXP, function (char) { return ESCAPED_CHARS[char]; }); | ||
return message.replace(/([{}](?:.*[{}])?)/su, "'$1'"); | ||
} | ||
@@ -58,3 +51,3 @@ function printLiteralElement(_a) { | ||
if (typeof style === 'string') { | ||
return style; | ||
return printEscapedMessage(style); | ||
} | ||
@@ -61,0 +54,0 @@ else if (style.type === 1 /* date */) { |
{ | ||
"name": "intl-messageformat-parser", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Parses ICU Message strings into an AST via JavaScript.", | ||
@@ -44,3 +44,3 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/formatjs/formatjs", | ||
"gitHead": "a30fa203c2f1bc5bb4ec76087cb4eb6b5fb9bde2" | ||
"gitHead": "8b6196ba1069961d905525a2f89319abd3ffed8d" | ||
} |
@@ -235,7 +235,8 @@ // tslint:disable:only-arrow-functions | ||
const peg$c21 = function(skeleton: any): any { return skeleton; }; | ||
const peg$c22 = ","; | ||
const peg$c23 = peg$literalExpectation(",", false); | ||
const peg$c24 = "number"; | ||
const peg$c25 = peg$literalExpectation("number", false); | ||
const peg$c26 = function(value: any, type: any, style: any): any { | ||
const peg$c22 = function(style: any): any { return style.replace(/\s*$/, ''); }; | ||
const peg$c23 = ","; | ||
const peg$c24 = peg$literalExpectation(",", false); | ||
const peg$c25 = "number"; | ||
const peg$c26 = peg$literalExpectation("number", false); | ||
const peg$c27 = function(value: any, type: any, style: any): any { | ||
return { | ||
@@ -248,3 +249,3 @@ type : type === 'number' ? TYPE.number : type === 'date' ? TYPE.date : TYPE.time, | ||
}; | ||
const peg$c27 = function(pattern: any): any { | ||
const peg$c28 = function(pattern: any): any { | ||
return { | ||
@@ -256,13 +257,13 @@ type: SKELETON_TYPE.date, | ||
}; | ||
const peg$c28 = "date"; | ||
const peg$c29 = peg$literalExpectation("date", false); | ||
const peg$c30 = "time"; | ||
const peg$c31 = peg$literalExpectation("time", false); | ||
const peg$c32 = "plural"; | ||
const peg$c33 = peg$literalExpectation("plural", false); | ||
const peg$c34 = "selectordinal"; | ||
const peg$c35 = peg$literalExpectation("selectordinal", false); | ||
const peg$c36 = "offset:"; | ||
const peg$c37 = peg$literalExpectation("offset:", false); | ||
const peg$c38 = function(value: any, pluralType: any, offset: any, options: any): any { | ||
const peg$c29 = "date"; | ||
const peg$c30 = peg$literalExpectation("date", false); | ||
const peg$c31 = "time"; | ||
const peg$c32 = peg$literalExpectation("time", false); | ||
const peg$c33 = "plural"; | ||
const peg$c34 = peg$literalExpectation("plural", false); | ||
const peg$c35 = "selectordinal"; | ||
const peg$c36 = peg$literalExpectation("selectordinal", false); | ||
const peg$c37 = "offset:"; | ||
const peg$c38 = peg$literalExpectation("offset:", false); | ||
const peg$c39 = function(value: any, pluralType: any, offset: any, options: any): any { | ||
return { | ||
@@ -283,5 +284,5 @@ type : TYPE.plural, | ||
}; | ||
const peg$c39 = "select"; | ||
const peg$c40 = peg$literalExpectation("select", false); | ||
const peg$c41 = function(value: any, options: any): any { | ||
const peg$c40 = "select"; | ||
const peg$c41 = peg$literalExpectation("select", false); | ||
const peg$c42 = function(value: any, options: any): any { | ||
return { | ||
@@ -300,5 +301,5 @@ type : TYPE.select, | ||
}; | ||
const peg$c42 = "="; | ||
const peg$c43 = peg$literalExpectation("=", false); | ||
const peg$c44 = function(id: any, value: any): any { | ||
const peg$c43 = "="; | ||
const peg$c44 = peg$literalExpectation("=", false); | ||
const peg$c45 = function(id: any, value: any): any { | ||
return { | ||
@@ -310,3 +311,3 @@ id, | ||
}; | ||
const peg$c45 = function(id: any, value: any): any { | ||
const peg$c46 = function(id: any, value: any): any { | ||
return { | ||
@@ -318,29 +319,29 @@ id, | ||
}; | ||
const peg$c46 = /^[\t-\r \x85\u200E\u200F\u2028\u2029]/; | ||
const peg$c47 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029"], false, false); | ||
const peg$c48 = /^[!-\/:-@[-\^`{-~\xA1-\xA7\xA9\xAB\xAC\xAE\xB0\xB1\xB6\xBB\xBF\xD7\xF7\u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E\u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]/; | ||
const peg$c49 = peg$classExpectation([["!", "/"], [":", "@"], ["[", "^"], "`", ["{", "~"], ["\xA1", "\xA7"], "\xA9", "\xAB", "\xAC", "\xAE", "\xB0", "\xB1", "\xB6", "\xBB", "\xBF", "\xD7", "\xF7", ["\u2010", "\u2027"], ["\u2030", "\u203E"], ["\u2041", "\u2053"], ["\u2055", "\u205E"], ["\u2190", "\u245F"], ["\u2500", "\u2775"], ["\u2794", "\u2BFF"], ["\u2E00", "\u2E7F"], ["\u3001", "\u3003"], ["\u3008", "\u3020"], "\u3030", "\uFD3E", "\uFD3F", "\uFE45", "\uFE46"], false, false); | ||
const peg$c50 = peg$otherExpectation("optional whitespace"); | ||
const peg$c51 = /^[0-9]/; | ||
const peg$c52 = peg$classExpectation([["0", "9"]], false, false); | ||
const peg$c53 = function(digits: any): any { | ||
const peg$c47 = /^[\t-\r \x85\u200E\u200F\u2028\u2029]/; | ||
const peg$c48 = peg$classExpectation([["\t", "\r"], " ", "\x85", "\u200E", "\u200F", "\u2028", "\u2029"], false, false); | ||
const peg$c49 = /^[!-\/:-@[-\^`{-~\xA1-\xA7\xA9\xAB\xAC\xAE\xB0\xB1\xB6\xBB\xBF\xD7\xF7\u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E\u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]/; | ||
const peg$c50 = peg$classExpectation([["!", "/"], [":", "@"], ["[", "^"], "`", ["{", "~"], ["\xA1", "\xA7"], "\xA9", "\xAB", "\xAC", "\xAE", "\xB0", "\xB1", "\xB6", "\xBB", "\xBF", "\xD7", "\xF7", ["\u2010", "\u2027"], ["\u2030", "\u203E"], ["\u2041", "\u2053"], ["\u2055", "\u205E"], ["\u2190", "\u245F"], ["\u2500", "\u2775"], ["\u2794", "\u2BFF"], ["\u2E00", "\u2E7F"], ["\u3001", "\u3003"], ["\u3008", "\u3020"], "\u3030", "\uFD3E", "\uFD3F", "\uFE45", "\uFE46"], false, false); | ||
const peg$c51 = peg$otherExpectation("optional whitespace"); | ||
const peg$c52 = /^[0-9]/; | ||
const peg$c53 = peg$classExpectation([["0", "9"]], false, false); | ||
const peg$c54 = function(digits: any): any { | ||
return parseInt(digits.join(''), 10); | ||
}; | ||
const peg$c54 = peg$otherExpectation("apostrophe"); | ||
const peg$c55 = "'"; | ||
const peg$c56 = peg$literalExpectation("'", false); | ||
const peg$c57 = peg$otherExpectation("double apostrophes"); | ||
const peg$c58 = "''"; | ||
const peg$c59 = peg$literalExpectation("''", false); | ||
const peg$c60 = function(): any { return `'`; }; | ||
const peg$c61 = /^[{}]/; | ||
const peg$c62 = peg$classExpectation(["{", "}"], false, false); | ||
const peg$c63 = /^[^']/; | ||
const peg$c64 = peg$classExpectation(["'"], true, false); | ||
const peg$c65 = function(escapedChar: any, quotedChars: any): any { | ||
const peg$c55 = peg$otherExpectation("apostrophe"); | ||
const peg$c56 = "'"; | ||
const peg$c57 = peg$literalExpectation("'", false); | ||
const peg$c58 = peg$otherExpectation("double apostrophes"); | ||
const peg$c59 = "''"; | ||
const peg$c60 = peg$literalExpectation("''", false); | ||
const peg$c61 = function(): any { return `'`; }; | ||
const peg$c62 = /^[{}]/; | ||
const peg$c63 = peg$classExpectation(["{", "}"], false, false); | ||
const peg$c64 = /^[^']/; | ||
const peg$c65 = peg$classExpectation(["'"], true, false); | ||
const peg$c66 = function(escapedChar: any, quotedChars: any): any { | ||
return escapedChar + quotedChars.replace(`''`, `'`); | ||
}; | ||
const peg$c66 = /^[^{}]/; | ||
const peg$c67 = peg$classExpectation(["{", "}"], true, false); | ||
const peg$c68 = peg$otherExpectation("keyword"); | ||
const peg$c67 = /^[^{}]/; | ||
const peg$c68 = peg$classExpectation(["{", "}"], true, false); | ||
const peg$c69 = peg$otherExpectation("keyword"); | ||
@@ -884,3 +885,9 @@ let peg$currPos = 0; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsekeyword(); | ||
s0 = peg$currPos; | ||
s1 = peg$parsemessageText(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c22(s1); | ||
} | ||
s0 = s1; | ||
} | ||
@@ -910,7 +917,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c22; | ||
s5 = peg$c23; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -920,8 +927,8 @@ if (s5 !== peg$FAILED) { | ||
if (s6 !== peg$FAILED) { | ||
if (input.substr(peg$currPos, 6) === peg$c24) { | ||
s7 = peg$c24; | ||
if (input.substr(peg$currPos, 6) === peg$c25) { | ||
s7 = peg$c25; | ||
peg$currPos += 6; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c25); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c26); } | ||
} | ||
@@ -933,7 +940,7 @@ if (s7 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s10 = peg$c22; | ||
s10 = peg$c23; | ||
peg$currPos++; | ||
} else { | ||
s10 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -974,3 +981,3 @@ if (s10 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c26(s3, s7, s9); | ||
s1 = peg$c27(s3, s7, s9); | ||
s0 = s1; | ||
@@ -1032,3 +1039,3 @@ } else { | ||
peg$savedPos = s0; | ||
s1 = peg$c27(s1); | ||
s1 = peg$c28(s1); | ||
} | ||
@@ -1066,3 +1073,9 @@ s0 = s1; | ||
if (s0 === peg$FAILED) { | ||
s0 = peg$parsekeyword(); | ||
s0 = peg$currPos; | ||
s1 = peg$parsemessageText(); | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c22(s1); | ||
} | ||
s0 = s1; | ||
} | ||
@@ -1092,7 +1105,7 @@ | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c22; | ||
s5 = peg$c23; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -1102,16 +1115,16 @@ if (s5 !== peg$FAILED) { | ||
if (s6 !== peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c28) { | ||
s7 = peg$c28; | ||
if (input.substr(peg$currPos, 4) === peg$c29) { | ||
s7 = peg$c29; | ||
peg$currPos += 4; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c29); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c30); } | ||
} | ||
if (s7 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 4) === peg$c30) { | ||
s7 = peg$c30; | ||
if (input.substr(peg$currPos, 4) === peg$c31) { | ||
s7 = peg$c31; | ||
peg$currPos += 4; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c31); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c32); } | ||
} | ||
@@ -1124,7 +1137,7 @@ } | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s10 = peg$c22; | ||
s10 = peg$c23; | ||
peg$currPos++; | ||
} else { | ||
s10 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -1165,3 +1178,3 @@ if (s10 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c26(s3, s7, s9); | ||
s1 = peg$c27(s3, s7, s9); | ||
s0 = s1; | ||
@@ -1250,7 +1263,7 @@ } else { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c22; | ||
s5 = peg$c23; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -1260,16 +1273,16 @@ if (s5 !== peg$FAILED) { | ||
if (s6 !== peg$FAILED) { | ||
if (input.substr(peg$currPos, 6) === peg$c32) { | ||
s7 = peg$c32; | ||
if (input.substr(peg$currPos, 6) === peg$c33) { | ||
s7 = peg$c33; | ||
peg$currPos += 6; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c33); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c34); } | ||
} | ||
if (s7 === peg$FAILED) { | ||
if (input.substr(peg$currPos, 13) === peg$c34) { | ||
s7 = peg$c34; | ||
if (input.substr(peg$currPos, 13) === peg$c35) { | ||
s7 = peg$c35; | ||
peg$currPos += 13; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c35); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c36); } | ||
} | ||
@@ -1281,7 +1294,7 @@ } | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s9 = peg$c22; | ||
s9 = peg$c23; | ||
peg$currPos++; | ||
} else { | ||
s9 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -1292,8 +1305,8 @@ if (s9 !== peg$FAILED) { | ||
s11 = peg$currPos; | ||
if (input.substr(peg$currPos, 7) === peg$c36) { | ||
s12 = peg$c36; | ||
if (input.substr(peg$currPos, 7) === peg$c37) { | ||
s12 = peg$c37; | ||
peg$currPos += 7; | ||
} else { | ||
s12 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c37); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c38); } | ||
} | ||
@@ -1347,3 +1360,3 @@ if (s12 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c38(s3, s7, s11, s13); | ||
s1 = peg$c39(s3, s7, s11, s13); | ||
s0 = s1; | ||
@@ -1433,7 +1446,7 @@ } else { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s5 = peg$c22; | ||
s5 = peg$c23; | ||
peg$currPos++; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -1443,8 +1456,8 @@ if (s5 !== peg$FAILED) { | ||
if (s6 !== peg$FAILED) { | ||
if (input.substr(peg$currPos, 6) === peg$c39) { | ||
s7 = peg$c39; | ||
if (input.substr(peg$currPos, 6) === peg$c40) { | ||
s7 = peg$c40; | ||
peg$currPos += 6; | ||
} else { | ||
s7 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c40); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c41); } | ||
} | ||
@@ -1455,7 +1468,7 @@ if (s7 !== peg$FAILED) { | ||
if (input.charCodeAt(peg$currPos) === 44) { | ||
s9 = peg$c22; | ||
s9 = peg$c23; | ||
peg$currPos++; | ||
} else { | ||
s9 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c23); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c24); } | ||
} | ||
@@ -1487,3 +1500,3 @@ if (s9 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c41(s3, s11); | ||
s1 = peg$c42(s3, s11); | ||
s0 = s1; | ||
@@ -1552,7 +1565,7 @@ } else { | ||
if (input.charCodeAt(peg$currPos) === 61) { | ||
s2 = peg$c42; | ||
s2 = peg$c43; | ||
peg$currPos++; | ||
} else { | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c43); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c44); } | ||
} | ||
@@ -1613,3 +1626,3 @@ if (s2 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c44(s2, s5); | ||
s1 = peg$c45(s2, s5); | ||
s0 = s1; | ||
@@ -1673,3 +1686,3 @@ } else { | ||
peg$savedPos = s0; | ||
s1 = peg$c45(s2, s5); | ||
s1 = peg$c46(s2, s5); | ||
s0 = s1; | ||
@@ -1707,3 +1720,3 @@ } else { | ||
if (peg$c46.test(input.charAt(peg$currPos))) { | ||
if (peg$c47.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1713,3 +1726,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c47); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c48); } | ||
} | ||
@@ -1723,3 +1736,3 @@ | ||
if (peg$c48.test(input.charAt(peg$currPos))) { | ||
if (peg$c49.test(input.charAt(peg$currPos))) { | ||
s0 = input.charAt(peg$currPos); | ||
@@ -1729,3 +1742,3 @@ peg$currPos++; | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c49); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
} | ||
@@ -1755,3 +1768,3 @@ | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c50); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c51); } | ||
} | ||
@@ -1767,3 +1780,3 @@ | ||
s1 = []; | ||
if (peg$c51.test(input.charAt(peg$currPos))) { | ||
if (peg$c52.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1773,3 +1786,3 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c52); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c53); } | ||
} | ||
@@ -1779,3 +1792,3 @@ if (s2 !== peg$FAILED) { | ||
s1.push(s2); | ||
if (peg$c51.test(input.charAt(peg$currPos))) { | ||
if (peg$c52.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1785,3 +1798,3 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c52); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c53); } | ||
} | ||
@@ -1794,3 +1807,3 @@ } | ||
peg$savedPos = s0; | ||
s1 = peg$c53(s1); | ||
s1 = peg$c54(s1); | ||
} | ||
@@ -1807,7 +1820,7 @@ s0 = s1; | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s0 = peg$c55; | ||
s0 = peg$c56; | ||
peg$currPos++; | ||
} else { | ||
s0 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c57); } | ||
} | ||
@@ -1817,3 +1830,3 @@ peg$silentFails--; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c54); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c55); } | ||
} | ||
@@ -1829,12 +1842,12 @@ | ||
s0 = peg$currPos; | ||
if (input.substr(peg$currPos, 2) === peg$c58) { | ||
s1 = peg$c58; | ||
if (input.substr(peg$currPos, 2) === peg$c59) { | ||
s1 = peg$c59; | ||
peg$currPos += 2; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c59); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c60); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c60(); | ||
s1 = peg$c61(); | ||
} | ||
@@ -1845,3 +1858,3 @@ s0 = s1; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c57); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c58); } | ||
} | ||
@@ -1857,10 +1870,10 @@ | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s1 = peg$c55; | ||
s1 = peg$c56; | ||
peg$currPos++; | ||
} else { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c57); } | ||
} | ||
if (s1 !== peg$FAILED) { | ||
if (peg$c61.test(input.charAt(peg$currPos))) { | ||
if (peg$c62.test(input.charAt(peg$currPos))) { | ||
s2 = input.charAt(peg$currPos); | ||
@@ -1870,3 +1883,3 @@ peg$currPos++; | ||
s2 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c62); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c63); } | ||
} | ||
@@ -1876,11 +1889,11 @@ if (s2 !== peg$FAILED) { | ||
s4 = []; | ||
if (input.substr(peg$currPos, 2) === peg$c58) { | ||
s5 = peg$c58; | ||
if (input.substr(peg$currPos, 2) === peg$c59) { | ||
s5 = peg$c59; | ||
peg$currPos += 2; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c59); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c60); } | ||
} | ||
if (s5 === peg$FAILED) { | ||
if (peg$c63.test(input.charAt(peg$currPos))) { | ||
if (peg$c64.test(input.charAt(peg$currPos))) { | ||
s5 = input.charAt(peg$currPos); | ||
@@ -1890,3 +1903,3 @@ peg$currPos++; | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c65); } | ||
} | ||
@@ -1896,11 +1909,11 @@ } | ||
s4.push(s5); | ||
if (input.substr(peg$currPos, 2) === peg$c58) { | ||
s5 = peg$c58; | ||
if (input.substr(peg$currPos, 2) === peg$c59) { | ||
s5 = peg$c59; | ||
peg$currPos += 2; | ||
} else { | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c59); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c60); } | ||
} | ||
if (s5 === peg$FAILED) { | ||
if (peg$c63.test(input.charAt(peg$currPos))) { | ||
if (peg$c64.test(input.charAt(peg$currPos))) { | ||
s5 = input.charAt(peg$currPos); | ||
@@ -1910,3 +1923,3 @@ peg$currPos++; | ||
s5 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c64); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c65); } | ||
} | ||
@@ -1922,11 +1935,11 @@ } | ||
if (input.charCodeAt(peg$currPos) === 39) { | ||
s4 = peg$c55; | ||
s4 = peg$c56; | ||
peg$currPos++; | ||
} else { | ||
s4 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c56); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c57); } | ||
} | ||
if (s4 !== peg$FAILED) { | ||
peg$savedPos = s0; | ||
s1 = peg$c65(s2, s3); | ||
s1 = peg$c66(s2, s3); | ||
s0 = s1; | ||
@@ -1957,3 +1970,3 @@ } else { | ||
s0 = peg$currPos; | ||
if (peg$c66.test(input.charAt(peg$currPos))) { | ||
if (peg$c67.test(input.charAt(peg$currPos))) { | ||
s1 = input.charAt(peg$currPos); | ||
@@ -1963,3 +1976,3 @@ peg$currPos++; | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c67); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c68); } | ||
} | ||
@@ -2062,3 +2075,3 @@ if (s1 !== peg$FAILED) { | ||
s1 = peg$FAILED; | ||
if (peg$silentFails === 0) { peg$fail(peg$c68); } | ||
if (peg$silentFails === 0) { peg$fail(peg$c69); } | ||
} | ||
@@ -2065,0 +2078,0 @@ |
@@ -29,11 +29,2 @@ /* | ||
const ESCAPED_CHARS: Record<string, string> = { | ||
'\\': '\\\\', | ||
'\\#': '\\#', | ||
'{': '\\{', | ||
'}': '\\}' | ||
}; | ||
const ESAPE_CHARS_REGEXP = /\\#|[{}\\]/g; | ||
export function printAST(ast: MessageFormatElement[]): string { | ||
@@ -65,3 +56,3 @@ let printedNodes = ast.map(el => { | ||
function printEscapedMessage(message: string): string { | ||
return message.replace(ESAPE_CHARS_REGEXP, char => ESCAPED_CHARS[char]); | ||
return message.replace(/([{}](?:.*[{}])?)/su, `'$1'`); | ||
} | ||
@@ -94,3 +85,3 @@ | ||
if (typeof style === 'string') { | ||
return style; | ||
return printEscapedMessage(style); | ||
} else if (style.type === SKELETON_TYPE.date) { | ||
@@ -97,0 +88,0 @@ return `::${printEscapedMessage(style.pattern)}`; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
274616
7339