How to use the js-beautify.html function in js-beautify

To help you get started, we’ve selected a few js-beautify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mediamonks / muban / build-tools / script / build-html.js View on Github external
function renderPage(template, content, page, outputPath) {
  // render full html page
  const templateStandaloneResult = template({
    content,
    page,
    publicPath: config.dist.publicPath,
  });

  // make it pretty
  const html = beautifyHtml(templateStandaloneResult, { indent_size: 2 });

  // output to disk
  return new Promise((resolve, reject) => {
    fs.writeFile(path.resolve(outputPath, `${page}.html`), html, 'utf-8', (err, res) => {
      if (err) {
        reject(err);
      } else {
        resolve(res);
      }
    });
  });
}
github mjmlio / mjml-app / src / pages / Project / index.js View on Github external
getHTMLOutput() {
    const { preview, beautifyOutput } = this.props
    return beautifyOutput
      ? beautifyJS.html(preview.content, {
          indent_size: 2, // eslint-disable-line camelcase
          wrap_attributes_indent_size: 2, // eslint-disable-line camelcase
          max_preserve_newline: 0, // eslint-disable-line camelcase
          preserve_newlines: false, // eslint-disable-line camelcase
        })
      : preview.content
  }
github hanejs / hane / index.js View on Github external
async function main() {
  const { render, theme } = hane.runtime
  const result = await render.feed('# Render test')
  let html = await theme.render({
    categories: [],
    items: [
      {
        title: 'Hello World',
        content: result,
        pubDate: new Date().toString(),
      },
    ],
    tags: [],
  })
  if (hane.config.theme.beautify) {
    html = beautify_html(html, { indent_size: 2 })
  }
  try {
    await fs.mkdirAsync(distPath)
  } catch (e) {}
  await fs.writeFileAsync(path.join(distPath, 'index.html'), html)
  console.log('done')
}
github zanata / zanata-platform / server / zanata-frontend / src / frontend / app / containers / StyleGuide / index.js View on Github external
2
                Jacob
                Thornton
                @fat
              
              
                3
                Larry the Bird
                @twitter
              
            
          
          
            <h4>Code</h4>
            <pre>             {beautify.html(tablecode)}
            </pre>
          
        
        <span>
          <h2>Tabs</h2>
          <h3>Horizontal</h3>
          
            
            Tab 1 content
            
            Tab 2 content
            
            Tab 3 content
          
          <h3>Vertical</h3></span>
github luozhihua / sublime-vue-formatter / scripts / vue / formatter.js View on Github external
function beautifyTemplate(template, lang, options) {
  let result = ''

  switch (lang) {
    case 'pug':
      result = pug(template, options.pug)
      break;

    default:
      result = htmlBeautify(template, options.html)
  }
  return trim(result)
}
github vincentdchan / MDE / build / HTMLExportIndex.js View on Github external
return __awaiter(this, void 0, void 0, function* () {
        let data = yield util_1.Host.getExportHTML();
        data = htmlHead + data + headTail;
        codeMirror.setValue(js_beautify_1.html(data));
    });
}
github tasti / react-linkify / src / components / ExampleSection.jsx View on Github external
render() {
    return (
      <div>
        <pre style="{{padding:">          {beautifyhtml(
            ExampleSection.renderToStaticMarkup(this.props.element),
            {indent_size: 2, unformatted: []}
          )}
        </pre>
        <div>Renders to:</div>
        <div style="{{marginTop:">
          {this.props.element}
        </div>
      </div>
    );
  }
}
github salesforce-ux / design-system / scripts / gulp / pages.jsx View on Github external
const prettyHTML = _.memoize(html => beautify.html(html, {
  'indent_size': 2,
  'indent_char': ' ',
  'unformatted': ['a'],
  'wrap_line_length ': 78,
  'indent_inner_html': true
}));
github stovmascript / react-native-version / index.js View on Github external
plistFilenames.forEach((filename, index) =&gt; {
						const indent = detectIndent(plistFiles[index]);

						fs.writeFileSync(
							path.join(programOpts.ios, filename),
							stripIndents`
							
							
							` +
								"\n" +
								beautify(
									fs
										.readFileSync(path.join(programOpts.ios, filename), "utf8")
										.match(/[\s\S]*&lt;\/dict&gt;/)[0],
									Object.assign(
										{ end_with_newline: true },
										indent.type === "tab"
											? { indent_with_tabs: true }
											: { indent_size: indent.amount }
									)
								) +
								stripIndents`
							` +
								"\n"
						);
					});
				});
github zanata / zanata-platform / server / zanata-frontend / src / frontend / app / containers / StyleGuide / index.js View on Github external
<code>
                &lt;{'Col xs={6} xsOffset={6}'} /&gt;</code>
            
            
              <code>
                &lt;{'Col md={6} mdPush={6}'} /&gt;</code>
              <code>
                &lt;{'Col md={6} mdPull={6}'} /&gt;</code>
            
          
          
            <h4>Code</h4>
            <pre>              {beautify.html(gridcode)}
            </pre>
          
        
        <span>
          <h2>Colors</h2>
          <h3>Main colors</h3>
          <small>Hover for hexcode</small><br>
          <div>
            <span>
              <span>#03A6D7</span></span></div>
          <div>
            <span>
              <span>#546677</span></span></div>
          <div>
            <span>
              <span>#629BAC</span></span></div></span>