( ast: MessageFormatElement[], isInPlural: boolean )
| 29 | } |
| 30 | |
| 31 | export function doPrintAST( |
| 32 | ast: MessageFormatElement[], |
| 33 | isInPlural: boolean |
| 34 | ): string { |
| 35 | const printedNodes = ast.map((el, i) => { |
| 36 | if (isLiteralElement(el)) { |
| 37 | return printLiteralElement(el, isInPlural, i === 0, i === ast.length - 1) |
| 38 | } |
| 39 | |
| 40 | if (isArgumentElement(el)) { |
| 41 | return printArgumentElement(el) |
| 42 | } |
| 43 | if (isDateElement(el) || isTimeElement(el) || isNumberElement(el)) { |
| 44 | return printSimpleFormatElement(el) |
| 45 | } |
| 46 | |
| 47 | if (isPluralElement(el)) { |
| 48 | return printPluralElement(el) |
| 49 | } |
| 50 | |
| 51 | if (isSelectElement(el)) { |
| 52 | return printSelectElement(el) |
| 53 | } |
| 54 | |
| 55 | if (isPoundElement(el)) { |
| 56 | return '#' |
| 57 | } |
| 58 | if (isTagElement(el)) { |
| 59 | return printTagElement(el) |
| 60 | } |
| 61 | }) |
| 62 | |
| 63 | return printedNodes.join('') |
| 64 | } |
| 65 | |
| 66 | function printTagElement(el: TagElement): string { |
| 67 | return `<${el.value}>${printAST(el.children)}</${el.value}>` |
no test coverage detected