From bbc400f4685f7b3af99b2e7a4b6b6d3c0293360f Mon Sep 17 00:00:00 2001 From: Vinarnt Date: Mon, 23 Aug 2021 12:51:46 +0200 Subject: [PATCH 1/2] Added beautify option --- Dockerfile | 1 + README.md | 13 +++++++++---- index.js | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index ff3861e..0e961fb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,6 +7,7 @@ ENV CORS="" ENV MJML_KEEP_COMMENTS=false ENV MJML_VALIDATION_LEVEL=soft ENV MJML_MINIFY=true +ENV MJML_MINIFY=false COPY package* ./ diff --git a/README.md b/README.md index 505232d..0e038ba 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,12 @@ Due to various challenges this image sports the following features: - Supports healthchecks. # Table of contents -- [Overview](#overview) -- [Defaults](#defaults) -- [Development](#development) -- [Troubleshooting](#troubleshooting) +- [MJML docker microservice / server](#mjml-docker-microservice--server) +- [Table of contents](#table-of-contents) + - [Overview](#overview) + - [Defaults](#defaults) + - [Development](#development) + - [Troubleshooting](#troubleshooting) ## Overview @@ -45,6 +47,7 @@ services: # - MJML_KEEP_COMMENTS=true # - MJML_VALIDATION_LEVEL=strict # - MJML_MINIFY=false + # - MJML_BEAUTIFY=true ``` ## Defaults @@ -56,6 +59,7 @@ CORS "" MJML_KEEP_COMMENTS "false" MJML_VALIDATION_LEVEL "soft" MJML_MINIFY "true" +MJML_BEAUTIFY "false" ``` ## Development @@ -67,6 +71,7 @@ CORS "*" MJML_KEEP_COMMENTS "true" MJML_VALIDATION_LEVEL "strict" MJML_MINIFY "false" +MJML_BEAUTIFY "true" ``` This will escalate any issues you have with invalid mjml code to the docker log (`stdout` or `docker-compose logs`). diff --git a/index.js b/index.js index 8a000c9..f6afe0e 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,7 @@ app.use(bodyParser.text({ const opts = { keepComments: (process.env.MJML_KEEP_COMMENTS === 'true'), minify: (process.env.MJML_MINIFY === 'true'), + beautify: (process.env.MJML_BEAUTIFY === 'true'), validationLevel: (['soft', 'strict', 'skip'].includes(process.env.MJML_VALIDATION_LEVEL) ? process.env.MJML_VALIDATION_LEVEL : 'soft'), } @@ -81,5 +82,6 @@ console.log('cors: ' + (process.env.CORS || 'n/a')) console.log('mjml keep comments: ' + opts.keepComments) console.log('mjml validation level: ' + opts.validationLevel) console.log('mjml minify: ' + opts.minify) +console.log('mjml beautify: ' + opts.beautify) console.log('') console.log('POST mjml as text/plain raw body, result will be returned as text/html.') From 3ee50492ad9ca639b6ea173a209d169b2c71e8cf Mon Sep 17 00:00:00 2001 From: Vinarnt Date: Mon, 23 Aug 2021 14:49:45 +0200 Subject: [PATCH 2/2] Removed automagically added entries to TOC --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 0e038ba..f8a001d 100644 --- a/README.md +++ b/README.md @@ -10,8 +10,6 @@ Due to various challenges this image sports the following features: - Supports healthchecks. # Table of contents -- [MJML docker microservice / server](#mjml-docker-microservice--server) -- [Table of contents](#table-of-contents) - [Overview](#overview) - [Defaults](#defaults) - [Development](#development)