From 50184739c7f2e30aeda1fc9067ae8887149e15f5 Mon Sep 17 00:00:00 2001 From: Roman Hotsiy Date: Thu, 17 May 2018 11:43:53 +0300 Subject: [PATCH] fix(cli): escape \u2029 \u2028 characters see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/ related to #475 --- cli/index.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cli/index.ts b/cli/index.ts index 9ca87dc5..df30a5c2 100644 --- a/cli/index.ts +++ b/cli/index.ts @@ -67,7 +67,7 @@ yargs console.log(e.stack); } }, -) + ) .command( 'bundle [spec]', 'bundle spec into zero-dependency HTML-file', @@ -112,7 +112,7 @@ yargs console.log(e.message); } }, -) + ) .demandCommand() .options('t', { alias: 'template', @@ -219,20 +219,20 @@ async function getPageHTML( redocHTML: `
${(ssr && html) || ''}
`, redocHead: ssr ? (cdn - ? '' - : ``) + css + ? '' + : ``) + css : '', title: title, }); @@ -288,3 +288,8 @@ function debounce(callback: Function, time: number) { function isURL(str: string): boolean { return /^(https?:)\/\//m.test(str); } + +// see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/ +function escapeUnicode(str) { + return str.replace(/\u2028|\u2029/g, m => '\\u202' + (m === '\u2028' ? '8' : '9')); +}