From cbf06bf3888c70dc7ffb5efd7da9291452c3c38b Mon Sep 17 00:00:00 2001 From: Ika Date: Sun, 16 Dec 2018 16:21:10 +0800 Subject: [PATCH] feat(html): format script with "application/ld+json" (#5642) --- src/language-html/utils.js | 4 ++++ .../__snapshots__/jsfmt.spec.js.snap | 19 +++++++++++++++++++ tests/html_script/jsfmt.spec.js | 1 + tests/html_script/script.html | 3 +++ 4 files changed, 27 insertions(+) create mode 100644 tests/html_script/__snapshots__/jsfmt.spec.js.snap create mode 100644 tests/html_script/jsfmt.spec.js create mode 100644 tests/html_script/script.html diff --git a/src/language-html/utils.js b/src/language-html/utils.js index 5b263eceb..ecbf5a139 100644 --- a/src/language-html/utils.js +++ b/src/language-html/utils.js @@ -375,6 +375,10 @@ function inferScriptParser(node) { if (node.attrMap.type === "text/markdown") { return "markdown"; } + + if (node.attrMap.type === "application/ld+json") { + return "json"; + } } if (node.name === "style") { diff --git a/tests/html_script/__snapshots__/jsfmt.spec.js.snap b/tests/html_script/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..18a5cad25 --- /dev/null +++ b/tests/html_script/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`script.html 1`] = ` +====================================options===================================== +parsers: ["html"] +printWidth: 80 + | printWidth +=====================================input====================================== + + +=====================================output===================================== + + +================================================================================ +`; diff --git a/tests/html_script/jsfmt.spec.js b/tests/html_script/jsfmt.spec.js new file mode 100644 index 000000000..53763df9b --- /dev/null +++ b/tests/html_script/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, ["html"]); diff --git a/tests/html_script/script.html b/tests/html_script/script.html new file mode 100644 index 000000000..5010a12a8 --- /dev/null +++ b/tests/html_script/script.html @@ -0,0 +1,3 @@ +