Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove beautify minify and migrate from mjml-core #2204

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,10 @@ option | unit | description | default value
fonts | object | Default fonts imported in the HTML rendered by HTML | See in [index.js](https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js#L36-L44)
keepComments | boolean | Option to keep comments in the HTML output | true
ignoreIncludes | boolean | Option to ignore mj-includes | false
beautify | boolean | Option to beautify the HTML output | false
minify | boolean | Option to minify the HTML output | false
validationLevel | string | Available values for the [validator](https://github.com/mjmlio/mjml/tree/master/packages/mjml-validator#validating-mjml): 'strict', 'soft', 'skip' | 'soft'
filePath | string | Path of file, used for relative paths in mj-includes | '.'
preprocessors | array of functions | Preprocessors applied to the xml before parsing. Input must be xml, not json. Functions must be (xml: string) => string | []
juicePreserveTags | Preserve some tags when inlining css, see [mjml-cli documentation](https://github.com/mjmlio/mjml/blob/master/packages/mjml-cli/README.md) for more info | NA
minifyOptions | Options for html minifier, see [mjml-cli documentation](https://github.com/mjmlio/mjml/blob/master/packages/mjml-cli/README.md) for more info | NA
mjmlConfigPath | string | The path or directory of the `.mjmlconfig` file (for custom components use) | `process.cwd()`
useMjmlConfigOptions | Allows to use the `config` attribute from `.mjmlconfig` file | false

Expand Down
3 changes: 0 additions & 3 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,10 @@ option | unit | description | default value
-------------|--------|--------------|---------------
fonts | object | Default fonts imported in the HTML rendered by HTML | See in [index.js](https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js#L36-L44)
keepComments | boolean | Option to keep comments in the HTML output | true
beautify | boolean | Option to beautify the HTML output | false
minify | boolean | Option to minify the HTML output | false
validationLevel | string | Available values for the [validator](https://github.com/mjmlio/mjml/tree/master/packages/mjml-validator#validating-mjml): 'strict', 'soft', 'skip' | 'soft'
filePath | string | Full path of the specified file to use when resolving paths from [`mj-include` components](#mj-include) | '.'
mjmlConfigPath | string | The path or directory of the [`.mjmlconfig` file](#community-components) | `process.cwd()`
useMjmlConfigOptions | Allows to use the `config` attribute from `.mjmlconfig` file | false
minifyOptions | Options for html minifier, see [mjml-cli documentation](https://github.com/mjmlio/mjml/blob/master/packages/mjml-cli/README.md) for more info | {"collapseWhitespace": true, "minifyCSS": false, "removeEmptyAttributes": true}
juicePreserveTags | optional setting when inlining css, see [mjml-cli documentation](https://github.com/mjmlio/mjml/blob/master/packages/mjml-cli/README.md) for more info | NA

## API
Expand Down
3 changes: 0 additions & 3 deletions packages/mjml-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
"@babel/runtime": "^7.8.7",
"cheerio": "1.0.0-rc.3",
"detect-node": "2.0.4",
"html-minifier": "^4.0.0",
"js-beautify": "^1.6.14",
"juice": "^7.0.0",
"lodash": "^4.17.15",
"mjml-migrate": "4.9.0",
"mjml-parser-xml": "4.9.0",
"mjml-validator": "4.9.0"
},
Expand Down
25 changes: 2 additions & 23 deletions packages/mjml-core/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ import {
} from 'lodash'
import path from 'path'
import juice from 'juice'
import { html as htmlBeautify } from 'js-beautify'
import { minify as htmlMinify } from 'html-minifier'
import cheerio from 'cheerio'

import MJMLParser from 'mjml-parser-xml'
import MJMLValidator, {
dependencies as globalDependencies,
assignDependencies,
} from 'mjml-validator'
import { handleMjml3 } from 'mjml-migrate'

import { initComponent } from './createComponent'
import globalComponents, {
Expand Down Expand Up @@ -109,7 +106,6 @@ export default function mjml2html(mjml, options = {}) {
validationLevel = 'soft',
filePath = '.',
actualPath = '.',
noMigrateWarn = false,
preprocessors,
presets = [],
} = {
Expand All @@ -135,8 +131,6 @@ export default function mjml2html(mjml, options = {}) {
})
}

mjml = handleMjml3(mjml, { noMigrateWarn })

const globalDatas = {
backgroundColor: '',
breakpoint: '480px',
Expand Down Expand Up @@ -362,29 +356,14 @@ export default function mjml2html(mjml, options = {}) {
if (beautify) {
// eslint-disable-next-line no-console
console.warn(
'"beautify" option is deprecated in mjml-core and only available in mjml cli.',
'"beautify" option has been removed in mjml-core and only available in mjml cli.',
)
content = htmlBeautify(content, {
indent_size: 2,
wrap_attributes_indent_size: 2,
max_preserve_newline: 0,
preserve_newlines: false,
})
}

if (minify) {
// eslint-disable-next-line no-console
console.warn(
'"minify" option is deprecated in mjml-core and only available in mjml cli.',
'"minify" option has been removed in mjml-core and only available in mjml cli.',
)

content = htmlMinify(content, {
collapseWhitespace: true,
minifyCSS: false,
caseSensitive: true,
removeEmptyAttributes: true,
...minifyOptions,
})
}

return {
Expand Down
3 changes: 0 additions & 3 deletions packages/mjml/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,10 @@ option | unit | description | default value
fonts | object | Default fonts imported in the HTML rendered by HTML | See in [index.js](https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js#L36-L44)
keepComments | boolean | Option to keep comments in the HTML output | true
ignoreIncludes | boolean | Option to ignore mj-includes | false
beautify | boolean | Option to beautify the HTML output | false
minify | boolean | Option to minify the HTML output | false
validationLevel | string | Available values for the [validator](https://github.com/mjmlio/mjml/tree/master/packages/mjml-validator#validating-mjml): 'strict', 'soft', 'skip' | 'soft'
filePath | string | Path of file, used for relative paths in mj-includes | '.'
preprocessors | array of functions | Preprocessors applied to the xml before parsing. Input must be xml, not json. Functions must be (xml: string) => string | []
juicePreserveTags | Preserve some tags when inlining css, see [mjml-cli documentation](https://github.com/mjmlio/mjml/blob/master/packages/mjml-cli/README.md) for more info | NA
minifyOptions | Options for html minifier, see [mjml-cli documentation](https://github.com/mjmlio/mjml/blob/master/packages/mjml-cli/README.md) for more info | NA
mjmlConfigPath | string | The path or directory of the `.mjmlconfig` file (for custom components use) | `process.cwd()`
useMjmlConfigOptions | Allows to use the `config` attribute from `.mjmlconfig` file | false

Expand Down
3 changes: 0 additions & 3 deletions readme-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,10 @@ console.log(htmlOutput)
fonts | object | 初期フォントをインポートしたHTMLを描画する | 初期フォントについては[index.js](https://github.com/mjmlio/mjml/blob/master/packages/mjml-core/src/index.js#L36-L44)をご覧ください。
keepComments | boolean | 出力されるHTMLにコメントを残すオプション | true
ignoreIncludes | boolean | mj-includesを無視するオプション | false
beautify | boolean | 出力されるHTMLを整えるオプション | false
minify | boolean | 出力されるHTMLをminify化するオプション | false
validationLevel | string | [validator](https://github.com/mjmlio/mjml/tree/master/packages/mjml-validator#validating-mjml)で利用する値: 'strict', 'soft', 'skip' | 'soft'
filePath | string | mj-includesの相対パスに使われるファイルパス | '.'
preprocessors | array of functions | xmlのパース前に適用するプリプロセッサー。入力はjsonではなく、必ずxmlでなければなりません。関数の場合は必ず (xml: string) => string としなければなりません。 | []
juicePreserveTags | cssをインライン化する際にタグを保持する。詳しくは[mjml-cli documentation](https://github.com/mjmlio/mjml/blob/master/packages/mjml-cli/README.md)をご覧ください。 | NA
minifyOptions | htmlのminify化に関するオプション。詳しくは[mjml-cli documentation](https://github.com/mjmlio/mjml/blob/master/packages/mjml-cli/README.md)をご覧ください。 | NA
mjmlConfigPath | string | `.mjmlconfig`ファイルのパスもしくはディレクトリー(カスタムコンポーネントの場合) | `process.cwd()`
useMjmlConfigOptions | `.mjmlconfig`ファイルで`config`属性の使用を許可する | false

Expand Down