intl-messageformat throws error when HTML included in message
See original GitHub issueWith the latest release and move to the latest intl-messageformat messages that include variables and HTML tags have started to throw errors.
This has been caused by a new option and functionality in intl-messageformat, ignoreTag
that is defaulted to false and not exposed or set by svelte-i18n.
Logs SyntaxError: Expected “#”, “'”, “\n”, “{”, argumentElement, double apostrophes, end of input, or tagElement but “<” found.
To Reproduce I will open a PR and reference in comments.
Expected behavior Messages with variables and HTML continue to behave as they have done and b rendered correctly.
Stacktraces
If you have a stack trace to include, we recommend putting inside a <details>
block for the sake of the thread’s readability:
Stack trace
SyntaxError: Expected “#”, “'”, “\n”, “{”, argumentElement, double apostrophes, end of input, or tagElement but “<” found. at peg$buildStructuredError (svelte-i18n/node_modules/intl-messageformat-parser/src/parser.js:401:16) at Object.peg$parse [as pegParse] (svelte-i18n/node_modules/intl-messageformat-parser/src/parser.js:3109:15) at Function.parse [as __parse] (svelte-i18n/node_modules/intl-messageformat-parser/index.js:11:24) at new IntlMessageFormat (svelte-i18n/node_modules/intl-messageformat/src/core.js:138:42) at svelte-i18n/src/runtime/includes/formatters.ts:94:5 at Object.memoizedFn (svelte-i18n/src/runtime/includes/memoize.ts:13:31) at Object.<anonymous> (svelte-i18n/test/runtime/includes/formatters.test.ts:201:7) at Object.asyncJestTest (svelte-i18n/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37) at svelte-i18n/node_modules/jest-jasmine2/build/queueRunner.js:45:12 at new Promise (<anonymous>) at mapper (svelte-i18n/node_modules/jest-jasmine2/build/queueRunner.js:28:19) at svelte-i18n/node_modules/jest-jasmine2/build/queueRunner.js:75:41 at processTicksAndRejections (internal/process/task_queues.js:93:5)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Hey @cupcakearmy, you can work around not having this option by escaping your HTML tags, e.g.
Fixed in 3.3.2 🎉 thanks @superafroman!