MCPcopy Index your code
hub / github.com/formatjs/formatjs / printEscapedMessage

Function printEscapedMessage

packages/icu-messageformat-parser/printer.ts:100–128  ·  view source on GitHub ↗
(message: string, isInPlural = false)

Source from the content-addressed store, hash-verified

98}
99
100function printEscapedMessage(message: string, isInPlural = false): string {
101 let result = ''
102 let literalStart = 0
103
104 function quoteToken(start: number, end: number) {
105 result += message.slice(literalStart, start)
106 result += quoteSyntaxToken(message.slice(start, end))
107 literalStart = end
108 }
109
110 for (let i = 0; i < message.length; i++) {
111 const ch = message[i]
112 if (ch === '{') {
113 const end = findBraceSyntaxEnd(message, i)
114 quoteToken(i, end)
115 i = end - 1
116 } else if (ch === '}') {
117 quoteToken(i, i + 1)
118 } else if (isTagSyntaxStart(message, i)) {
119 const end = findTagSyntaxEnd(message, i)
120 quoteToken(i, end)
121 i = end - 1
122 } else if (isInPlural && ch === '#') {
123 quoteToken(i, i + 1)
124 }
125 }
126
127 return result + message.slice(literalStart)
128}
129
130function printLiteralElement(
131 {value}: LiteralElement,

Callers 2

printLiteralElementFunction · 0.85
printArgumentStyleFunction · 0.85

Calls 4

findBraceSyntaxEndFunction · 0.85
quoteTokenFunction · 0.85
isTagSyntaxStartFunction · 0.85
findTagSyntaxEndFunction · 0.85

Tested by

no test coverage detected