From 190cd960664a26a671b8abb4eff5b51330ec7450 Mon Sep 17 00:00:00 2001 From: Ritesh Kumar Date: Wed, 26 Jan 2022 11:47:02 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20(html-to-jsx)=20remove=20semicol?= =?UTF-8?q?on=20at=20start=20and=20keep=20empty=20prop=20values=20(#321)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fixes #310 * :bug: (html-to-jsx) remove semicolon at start and keep empty prop values Closes #279, closes #319 --- components/ConversionPanel.tsx | 7 ++++++- package.json | 2 +- patches/htmltojsx+0.3.0.patch | 11 ++++++++++- ...wasm+0.6.1.patch => json_typegen_wasm+0.7.0.patch} | 0 4 files changed, 17 insertions(+), 3 deletions(-) rename patches/{json_typegen_wasm+0.6.1.patch => json_typegen_wasm+0.7.0.patch} (100%) diff --git a/components/ConversionPanel.tsx b/components/ConversionPanel.tsx index 1e3e358..fa38a73 100644 --- a/components/ConversionPanel.tsx +++ b/components/ConversionPanel.tsx @@ -95,10 +95,15 @@ const ConversionPanel: React.FunctionComponent = function( splitEditorValue: splitTitle ? splitValue : undefined }); - const prettyResult = await prettierWorker.send({ + let prettyResult = await prettierWorker.send({ value: result, language: resultLanguage }); + + // Fix for #319 + if (prettyResult.startsWith(";<")) { + prettyResult = prettyResult.slice(1); + } setResult(prettyResult); setMessage(""); } catch (e) { diff --git a/package.json b/package.json index 67d333f..1927136 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "build:analyze": "ANALYZE=true yarn build" }, "engines": { - "node": "12.x" + "node": "14.x" }, "dependencies": { "@babel/plugin-transform-flow-strip-types": "^7.16.0", diff --git a/patches/htmltojsx+0.3.0.patch b/patches/htmltojsx+0.3.0.patch index f0f2cef..ac2f01c 100644 --- a/patches/htmltojsx+0.3.0.patch +++ b/patches/htmltojsx+0.3.0.patch @@ -1,5 +1,5 @@ diff --git a/node_modules/htmltojsx/src/htmltojsx.js b/node_modules/htmltojsx/src/htmltojsx.js -index afe4c85..b326beb 100644 +index afe4c85..960e450 100644 --- a/node_modules/htmltojsx/src/htmltojsx.js +++ b/node_modules/htmltojsx/src/htmltojsx.js @@ -326,19 +326,9 @@ HTMLtoJSX.prototype = { @@ -44,3 +44,12 @@ index afe4c85..b326beb 100644 return this.output; }, +@@ -627,6 +618,8 @@ HTMLtoJSX.prototype = { + result += '={' + attribute.value + '}'; + } else if (attribute.value.length > 0) { + result += '="' + attribute.value.replace(/"/gm, '"') + '"'; ++ } else { ++ result += '=""'; + } + return result; + } diff --git a/patches/json_typegen_wasm+0.6.1.patch b/patches/json_typegen_wasm+0.7.0.patch similarity index 100% rename from patches/json_typegen_wasm+0.6.1.patch rename to patches/json_typegen_wasm+0.7.0.patch