diff --git a/docs/userGuide/siteConfiguration.md b/docs/userGuide/siteConfiguration.md index bbda149c56..5ac44b6c66 100644 --- a/docs/userGuide/siteConfiguration.md +++ b/docs/userGuide/siteConfiguration.md @@ -202,6 +202,18 @@ The example above uses tags as an example of configuring plugin settings, refer **Specifies that the website should use MarkBind's search functionality.** Default: `true`. See [User Guide: Making the Site Searchable](makingTheSiteSearchable.html) for more details. +#### **`disableHtmlBeautify`** + +**Turn off html beautification done by [js-beautify](https://github.com/beautify-web/js-beautify) for html files generated by MarkBind.** By default, MarkBind beautifies the HTML files it generates, which helps in user-friendly viewing and editing. +You can choose to turn this option off to improve the performance of the MarkBind `build` process. +
+To turn off the option, add the following to `site.json` - +```js +... +"disableHtmlBeautify": true, +... +``` + #### **`timeZone`** **Time zone of the [time stamp](reusingContents.html#built-in-variable-timestamp).** Default: `"UTC"`. diff --git a/package-lock.json b/package-lock.json index 95f86cee5c..601a5a64fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2193,14 +2193,13 @@ } }, "editorconfig": { - "version": "0.13.3", - "resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.13.3.tgz", - "integrity": "sha512-WkjsUNVCu+ITKDj73QDvi0trvpdDWdkDyHybDGSXPfekLCqwmpD7CP7iPbvBgosNuLcI96XTDwNa75JyFl7tEQ==", + "version": "0.15.3", + "resolved": "https://registry.npmjs.org/editorconfig/-/editorconfig-0.15.3.tgz", + "integrity": "sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g==", "requires": { - "bluebird": "^3.0.5", - "commander": "^2.9.0", - "lru-cache": "^3.2.0", - "semver": "^5.1.0", + "commander": "^2.19.0", + "lru-cache": "^4.1.5", + "semver": "^5.6.0", "sigmund": "^1.0.1" }, "dependencies": { @@ -5255,14 +5254,30 @@ } }, "js-beautify": { - "version": "1.7.5", - "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.7.5.tgz", - "integrity": "sha512-9OhfAqGOrD7hoQBLJMTA+BKuKmoEtTJXzZ7WDF/9gvjtey1koVLuZqIY6c51aPDjbNdNtIXAkiWKVhziawE9Og==", + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.10.3.tgz", + "integrity": "sha512-wfk/IAWobz1TfApSdivH5PJ0miIHgDoYb1ugSqHcODPmaYu46rYe5FVuIEkhjg8IQiv6rDNPyhsqbsohI/C2vQ==", "requires": { - "config-chain": "~1.1.5", - "editorconfig": "^0.13.2", - "mkdirp": "~0.5.0", - "nopt": "~3.0.1" + "config-chain": "^1.1.12", + "editorconfig": "^0.15.3", + "glob": "^7.1.3", + "mkdirp": "~0.5.1", + "nopt": "~4.0.1" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } } }, "js-tokens": { @@ -5784,11 +5799,12 @@ } }, "lru-cache": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-3.2.0.tgz", - "integrity": "sha1-cXibO39Tmb7IVl3aOKow0qCX7+4=", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "requires": { - "pseudomap": "^1.0.1" + "pseudomap": "^1.0.2", + "yallist": "^2.1.2" } }, "make-dir": { @@ -6351,11 +6367,12 @@ } }, "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.3.tgz", + "integrity": "sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==", "requires": { - "abbrev": "1" + "abbrev": "1", + "osenv": "^0.1.4" } }, "normalize-package-data": { @@ -6782,11 +6799,24 @@ "word-wrap": "~1.2.3" } }, + "os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=" + }, "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + }, + "osenv": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.5.tgz", + "integrity": "sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==", + "requires": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + } }, "p-each-series": { "version": "2.1.0", @@ -9565,6 +9595,11 @@ "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==", "dev": true }, + "yallist": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, "yaml": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/yaml/-/yaml-1.7.2.tgz", diff --git a/package.json b/package.json index 850a6549b7..afc81daf22 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "highlight.js": "^9.14.2", "htmlparser2": "^3.10.1", "ignore": "^5.1.4", - "js-beautify": "~1.7.5", + "js-beautify": "^1.10.3", "live-server": "^1.2.1", "lodash": "^4.17.15", "markdown-it": "^8.4.2", @@ -47,11 +47,11 @@ "markdown-it-linkify-images": "^1.1.1", "markdown-it-mark": "^2.0.0", "markdown-it-regexp": "^0.4.0", + "markdown-it-sub": "^1.0.0", + "markdown-it-sup": "^1.0.0", "markdown-it-table-of-contents": "^0.4.4", "markdown-it-task-lists": "^1.4.1", "markdown-it-video": "^0.6.3", - "markdown-it-sub": "^1.0.0", - "markdown-it-sup": "^1.0.0", "nunjucks": "^3.2.0", "path-is-inside": "^1.0.2", "progress": "^2.0.3", diff --git a/src/Page.js b/src/Page.js index 6e90d83232..e9d8d6d817 100644 --- a/src/Page.js +++ b/src/Page.js @@ -62,6 +62,7 @@ class Page { this.content = pageConfig.content || ''; this.faviconUrl = pageConfig.faviconUrl; this.frontmatterOverride = pageConfig.frontmatter || {}; + this.disableHtmlBeautify = pageConfig.disableHtmlBeautify; this.layout = pageConfig.layout; this.layoutsAssetPath = pageConfig.layoutsAssetPath; this.rootPath = pageConfig.rootPath; @@ -657,14 +658,14 @@ class Page { const pageNavTitleHtml = this.generatePageNavTitleHtml(); const pageNavHeadingHTML = this.generatePageNavHeadingHtml(); this.pageSectionsHtml[`#${PAGE_NAV_ID}`] - = htmlBeautify(`\n', Page.htmlBeautifyOptions); + = `\n'; } } @@ -755,10 +756,9 @@ class Page { if (pageSection.length === 0) { return; } - this.pageSectionsHtml[section] = htmlBeautify($.html(section), Page.htmlBeautifyOptions) - .trim(); + this.pageSectionsHtml[section] = $.html(section); pageSection.remove(); - this.content = htmlBeautify($.html(), Page.htmlBeautifyOptions); + this.content = $.html(); } collectAllPageSections() { @@ -803,7 +803,7 @@ class Page { .then(result => markbinder.processDynamicResources(this.sourcePath, result)) .then(result => MarkBind.unwrapIncludeSrc(result)) .then((result) => { - this.content = htmlBeautify(result, Page.htmlBeautifyOptions); + this.content = result; const { relative } = urlUtils.getParentSiteAbsoluteAndRelativePaths(this.sourcePath, this.rootPath, this.baseUrlMap); @@ -821,10 +821,12 @@ class Page { this.collectAllPageSections(); this.buildPageNav(); - return fs.outputFileAsync(this.resultPath, htmlBeautify( - this.template.render(this.prepareTemplateData()), - Page.htmlBeautifyOptions, - )); + const renderedTemplate = this.template.render(this.prepareTemplateData()); + const outputTemplateHTML = this.disableHtmlBeautify + ? renderedTemplate + : htmlBeautify(renderedTemplate, Page.htmlBeautifyOptions); + + return fs.outputFileAsync(this.resultPath, outputTemplateHTML); }) .then(() => { const resolvingFiles = []; @@ -1071,7 +1073,10 @@ class Page { baseUrl, hostBaseUrl, }); - return fs.outputFileAsync(resultPath, htmlBeautify(content, Page.htmlBeautifyOptions)); + const outputContentHTML = this.disableHtmlBeautify + ? content + : htmlBeautify(content, Page.htmlBeautifyOptions); + return fs.outputFileAsync(resultPath, outputContentHTML); }) .then(() => { // Recursion call to resolve nested dependency diff --git a/src/Site.js b/src/Site.js index e626ad1de3..e493f1399a 100644 --- a/src/Site.js +++ b/src/Site.js @@ -237,6 +237,7 @@ class Site { faviconUrl: config.faviconUrl, frontmatter: config.frontmatter, globalOverride: this.siteConfig.globalOverride || {}, + disableHtmlBeautify: this.siteConfig.disableHtmlBeautify, pageTemplate: this.pageTemplate, plugins: this.plugins || {}, rootPath: this.rootPath, @@ -943,7 +944,7 @@ class Site { injectMarkdownItSpecialTags(tagsToIgnore); Page.htmlBeautifyOptions = { indent_size: 2, - content_unformatted: ['pre', ...tagsToIgnore], + content_unformatted: ['pre', 'textarea', ...tagsToIgnore], }; } diff --git a/test/functional/test_site/expected/bugs/index.html b/test/functional/test_site/expected/bugs/index.html index 5b7bd96720..80288776b9 100644 --- a/test/functional/test_site/expected/bugs/index.html +++ b/test/functional/test_site/expected/bugs/index.html @@ -29,10 +29,12 @@
  • Open Bugs
  • -
    Test Jumbotron
    +
    + Test Jumbotron

    +

    Bug Description

    @@ -41,6 +43,8 @@

    Steps to Reproduce

    + +