Skip to content

Commit

Permalink
feat(html): format script with "application/ld+json" (#5642)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang committed Dec 16, 2018
1 parent 8e612f0 commit cbf06bf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/language-html/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
19 changes: 19 additions & 0 deletions tests/html_script/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`script.html 1`] = `
====================================options=====================================
parsers: ["html"]
printWidth: 80
| printWidth
=====================================input======================================
<script type="application/ld+json">
{ "json":true }
</script>
=====================================output=====================================
<script type="application/ld+json">
{ "json": true }
</script>
================================================================================
`;
1 change: 1 addition & 0 deletions tests/html_script/jsfmt.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
run_spec(__dirname, ["html"]);
3 changes: 3 additions & 0 deletions tests/html_script/script.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script type="application/ld+json">
{ "json":true }
</script>

0 comments on commit cbf06bf

Please sign in to comment.