How to use the js-beautify.css 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 victorporof / Sublime-HTMLPrettify / scripts / run.js View on Github external
fs.readFile(tempPath, "utf8", function(err, data) {
  if (err) {
    return;
  }

  // Mark the output as being from this plugin.
  console.log("*** HTMLPrettify output ***");

  if (isCSS(filePath, data)) {
    console.log(css_beautify(data, options["css"]));
  }
  else if (isHTML(filePath, data)) {
    console.log(html_beautify(data, options["html"]));
  }
  else if (isJS(filePath, data)) {
    console.log(js_beautify(data, options["js"]));
  }
});
github google / pagespeed-inslides / pagespeed.js View on Github external
// Fail silently if the resource is not available
            return resolve({
              url: url,
              beautified: beautified,
            });
          }
          if (/javascript/.test(type)) {
            beautified = Prism.highlight(beautifyJs(
                body.substr(0, CODE_CHARACTER_LIMIT + 160), beautifyOptions)
                .substr(0, CODE_CHARACTER_LIMIT), Prism.languages.javascript);
          } else if (/text\/html/.test(type)) {
            beautified = Prism.highlight(beautifyHtml(
                body.substr(0, CODE_CHARACTER_LIMIT + 160), beautifyOptions)
                .substr(0, CODE_CHARACTER_LIMIT), Prism.languages.markup);
          } else if (/text\/css/.test(type)) {
            beautified = Prism.highlight(beautifyCss(
                body.substr(0, CODE_CHARACTER_LIMIT + 160), beautifyOptions)
                .substr(0, CODE_CHARACTER_LIMIT), Prism.languages.css);
          }
          return resolve({
            url: url,
            beautified: beautified,
          });
        });
      }));
github ruslang02 / atomos / apps / angles / index.html View on Github external
if (event.ctrlKey && event.code === "KeyS") $(
					"[data-key='Ctrl+S']").click();
				if (event.ctrlKey && event.code === "KeyB") {
					let currentTab = editors[$('tab[active]').attr("id")];
					let settings = {
						indent_size: 1,
						indent_char: currentTab.getSession().getTabString(),
						indent_with_tabs: (currentTab.getSession().getTabString() === "\t"),
						wrap_line_length: currentTab.getSession().getWrapLimit()
					};
					let tabText = $(".nav-link[to=" + $('tab[active]').attr(
						"id") + "] name").text();
					let btext;
					if (tabText.endsWith(".js") || tabText.endsWith(".json")) btext =
						js_beautify(currentTab.getValue(), settings);
					else if (tabText.endsWith(".css")) btext = css_beautify(currentTab.getValue(),
						settings);
					else if (tabText.endsWith(".html")) btext = html_beautify(currentTab.getValue(),
						settings);
					else return;
					editors[$(`tab[active]`).attr("id")].setValue(btext);
				}
			});
github raphamorim / retro / src / components / Editor.js View on Github external
formatCode() {
      return false;

      const currentLine = code.getSelectionRange().start.row
      const mode = code.getSession().getMode().$id.split('/').pop()
      let val = code.session.getValue()

      if (mode === 'javascript') {
          code.session.setValue(js_beautify(val, data.format))
          code.gotoLine(currentLine + 1, Infinity)
      } else if (mode === 'html') {
          code.session.setValue(html(val, data.format))
          code.gotoLine(currentLine + 1, Infinity)
      } else if (mode === 'css') {
          code.session.setValue(css(val, data.format))
          code.gotoLine(currentLine + 1, Infinity)
      }
  }
github prixe / lindo / src / app / window / official-game-update / official-game-update.component.ts View on Github external
applyRegex(regex, files) {
        for (let filename in regex) {
            if (files[filename]) {
                if (/.js$/.test(filename)) {
                    files[filename] = BeautifyJs(files[filename], { "break_chained_methods": true });
                }
                else if (/.css$/.test(filename)) {
                    files[filename] = BeautifyCss(files[filename]);
                }
                for (let i in regex[filename]) {
                    files[filename] = files[filename].replace(new RegExp(regex[filename][i][0], 'g'), regex[filename][i][1]);
                }
            }
        }
    }
github win7killer / vue-format / src / index.js View on Github external
beautyCss(text) {
        let scoped = /]*\s+scoped/.test(text) ? ' scoped' : '';
        let lang = this.getLang(text);
        let str = text;
        text = text.replace(/]*>([\w\W]*)<\/style>/, '$1');
        if (text.trim()) {
            let tempConf = Object.assign({}, this.jsBeautifyConf, this.jsBeautifyConf.css);
            str = beautify.css(text, tempConf);
            return `\n${str}\n`;
        } else {
            return str;
        }
    },
    beautyJs(text) {
github ouqiang / mars / web / vue / src / App.vue View on Github external
case 'application/xml':
          const trimContent = this.trim(content)
          if (trimContent.indexOf('{') === 0 && trimContent.lastIndexOf('}') === trimContent.length - 1) {
            content = BeautifyJs(content)
          } else {
            content = BeautifyHtml(content)
          }
          break
        case 'text/javascript':
        case 'application/json':
        case 'application/javascript':
        case 'application/x-javascript':
          content = BeautifyJs(content)
          break
        case 'text/css':
          content = BeautifyCss(content)
          break
      }

      return content
    },
    trim (str) {
github jxnblk / superstyle / docs / CSS.js View on Github external
const CSS = props => {
  const css = sheet.css

  return (
    
      CSS for this page
      <code>{css.length} bytes</code>
      <pre>    
  )
}
</pre>
github creative-connections / Bodylight.js-Composer / src / runtime / Builder.js View on Github external
getCss() {
    let CSS = ''
    this.imports.forEach(({ css }) => CSS = CSS + css)

    return beautify.css(`
      ${CSS}
      ${getEditorCss()}
    `)
  }