@teleporthq/teleport-postprocessor-prettier-html
Advanced tools
Comparing version
@@ -6,3 +6,3 @@ import processor from '../src' | ||
const inputChunks = { | ||
html: `<div><span >Format me!</span> | ||
html: `<div><span >Format me!</span> | ||
</div>`, | ||
@@ -14,3 +14,3 @@ js: `import React from "react"; import {Link} from "react-router"`, | ||
expect(result.html).toBe('<div><span>Format me!</span> </div>\n') | ||
expect(result.html).toBe('<div><span>Format me!</span></div>\n') | ||
expect(result.js).toBe(inputChunks.js) | ||
@@ -17,0 +17,0 @@ }) |
@@ -5,2 +5,3 @@ import { PostProcessor, PrettierFormatOptions } from '@teleporthq/teleport-types'; | ||
formatOptions?: PrettierFormatOptions; | ||
strictHtmlWhitespaceSensitivity?: boolean; | ||
} | ||
@@ -7,0 +8,0 @@ export declare const createPrettierHTMLPostProcessor: (options?: PostProcessorFactoryOptions) => PostProcessor; |
@@ -27,5 +27,6 @@ "use strict"; | ||
var formatOptions = __assign(__assign({}, teleport_shared_1.Constants.PRETTIER_CONFIG), options.formatOptions); | ||
var htmlWhitespaceSensitivity = (options === null || options === void 0 ? void 0 : options.strictHtmlWhitespaceSensitivity) === true ? 'strict' : 'ignore'; | ||
var processor = function (codeChunks) { | ||
if (codeChunks[fileType]) { | ||
codeChunks[fileType] = format(codeChunks[fileType], __assign(__assign({}, formatOptions), { htmlWhitespaceSensitivity: 'strict', plugins: [parser_html_js_1.default], parser: 'html' })); | ||
codeChunks[fileType] = format(codeChunks[fileType], __assign(__assign({}, formatOptions), { htmlWhitespaceSensitivity: htmlWhitespaceSensitivity, plugins: [parser_html_js_1.default], parser: 'html' })); | ||
} | ||
@@ -32,0 +33,0 @@ else { |
@@ -5,2 +5,3 @@ import { PostProcessor, PrettierFormatOptions } from '@teleporthq/teleport-types'; | ||
formatOptions?: PrettierFormatOptions; | ||
strictHtmlWhitespaceSensitivity?: boolean; | ||
} | ||
@@ -7,0 +8,0 @@ export declare const createPrettierHTMLPostProcessor: (options?: PostProcessorFactoryOptions) => PostProcessor; |
@@ -21,5 +21,6 @@ var __assign = (this && this.__assign) || function () { | ||
var formatOptions = __assign(__assign({}, Constants.PRETTIER_CONFIG), options.formatOptions); | ||
var htmlWhitespaceSensitivity = (options === null || options === void 0 ? void 0 : options.strictHtmlWhitespaceSensitivity) === true ? 'strict' : 'ignore'; | ||
var processor = function (codeChunks) { | ||
if (codeChunks[fileType]) { | ||
codeChunks[fileType] = format(codeChunks[fileType], __assign(__assign({}, formatOptions), { htmlWhitespaceSensitivity: 'strict', plugins: [parserHTML], parser: 'html' })); | ||
codeChunks[fileType] = format(codeChunks[fileType], __assign(__assign({}, formatOptions), { htmlWhitespaceSensitivity: htmlWhitespaceSensitivity, plugins: [parserHTML], parser: 'html' })); | ||
} | ||
@@ -26,0 +27,0 @@ else { |
{ | ||
"name": "@teleporthq/teleport-postprocessor-prettier-html", | ||
"version": "0.32.8", | ||
"version": "0.32.10", | ||
"description": "A post-processing function that formats html code chunks using prettier and the prettier-html plugin", | ||
@@ -27,7 +27,7 @@ "author": "teleportHQ", | ||
"dependencies": { | ||
"@teleporthq/teleport-shared": "^0.32.7", | ||
"@teleporthq/teleport-types": "^0.32.7", | ||
"@teleporthq/teleport-shared": "^0.32.10", | ||
"@teleporthq/teleport-types": "^0.32.10", | ||
"prettier": "^2.3.1" | ||
}, | ||
"gitHead": "0296d8efac68e145c0b1fea00b90534749c5b8df" | ||
"gitHead": "5623a4dc037e2afd3e0217f1e1bb009e52cbb516" | ||
} |
@@ -11,2 +11,3 @@ import standalone from 'prettier/standalone.js' | ||
formatOptions?: PrettierFormatOptions | ||
strictHtmlWhitespaceSensitivity?: boolean | ||
} | ||
@@ -17,2 +18,4 @@ | ||
const formatOptions = { ...Constants.PRETTIER_CONFIG, ...options.formatOptions } | ||
const htmlWhitespaceSensitivity = | ||
options?.strictHtmlWhitespaceSensitivity === true ? 'strict' : 'ignore' | ||
@@ -23,3 +26,3 @@ const processor: PostProcessor = (codeChunks) => { | ||
...formatOptions, | ||
htmlWhitespaceSensitivity: 'strict', | ||
htmlWhitespaceSensitivity, | ||
plugins: [parserHTML], | ||
@@ -26,0 +29,0 @@ parser: 'html', |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
62185
1.47%152
4.83%