• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript js-beautify.html函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中js-beautify.html函数的典型用法代码示例。如果您正苦于以下问题:TypeScript html函数的具体用法?TypeScript html怎么用?TypeScript html使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了html函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: htmlFormat

export function htmlFormat(
  document: TextDocument,
  currRange: Range,
  formattingOptions: FormattingOptions,
  config: any
): TextEdit[] {
  const { value, range } = getValueAndRange(document, currRange);

  defaultHtmlOptions.indent_with_tabs = !formattingOptions.insertSpaces;
  defaultHtmlOptions.indent_size = formattingOptions.tabSize;

  const htmlFormattingOptions = _.assign(
    defaultHtmlOptions,
    config.tandem.paperclip.format.defaultFormatterOptions['js-beautify-html'],
    { end_with_newline: false }
  );

  const beautifiedHtml = htmlBeautify(templateHead + value + templateTail, htmlFormattingOptions);
  const wrappedHtml = beautifiedHtml.substring(templateHead.length, beautifiedHtml.length - templateTail.length);
  return [
    {
      range,
      newText: wrappedHtml
    }
  ];
}
开发者ID:cryptobuks,项目名称:tandem,代码行数:26,代码来源:htmlFormat.ts


示例2: serializeDocument

export function serializeDocument(document: Object, pretty?: boolean): string {
  const doc = parse5.serialize(document, { treeAdapter : parse5.treeAdapters.htmlparser2 });
  if (pretty) {
    const beautify: any = require('js-beautify');
    return beautify.html(doc, {indent_size: 2});
  }
  return doc;
}
开发者ID:jeffwhelpley,项目名称:universal,代码行数:8,代码来源:node-document.ts


示例3: serializeDocument

export function serializeDocument(document: Object, pretty?: boolean): string {
  const doc = serializer.serialize(document);
  if (pretty) {
    const beautify: any = require('js-beautify');
    return beautify.html(doc, {indent_size: 2});
  }
  return doc;
}
开发者ID:carloserodriguez2000,项目名称:universal,代码行数:8,代码来源:node-document.ts


示例4: beautifyHtml

export const printPrettyHtml = (html)=> {
  html = beautifyHtml( html, {"indent_size":2} )
    .replace(/class=/g, "className=")
    .replace(/<input([^>]*)>/g, "<input$1/>")
    .replace(/readonly=""/g,"readOnly={true}")
    .replace(/font-size/g,"fontSize")
    .replace(/style="([^"]+)"+/g, (match, style)=> {
      let reactStyle = map(compact(style.split(";")), (keyvalue)=> {
        let [key, value] = keyvalue.split(":")
        return `${key}:"${value}"`
      }).join(",")
      return "style={{" + reactStyle + "}}"
    })
  console.log("\n"+ html)
}
开发者ID:BenJamesbabala,项目名称:searchkit,代码行数:15,代码来源:TestHelpers.ts


示例5: getAllFilePaths

(() => {
  const failures: Failure[] = [];
  const filePaths = nonFlagsArgs.length > 0 ? nonFlagsArgs : getAllFilePaths();

  for (const filePath of filePaths) {
    const fileContents = readFile(filePath);
    const formattedFileContents = fixSelfClosingSlashes(formatHtml(fileContents, beautifyOptions));

    if (fileContents !== formattedFileContents) {
      if (options.fix) {
        writeFile(filePath, formattedFileContents);
      } else {
        failures.push({ filePath, message: 'html formatting' });
      }
    }
  }

  bailIfFailures(failures);
})();
开发者ID:kevinphelps,项目名称:kevinphelps.me,代码行数:19,代码来源:format-html.ts


示例6: beautifyJsLibChainHtml

  // Post-parser cleanup routines.  The parser is for getting into structure of the doc.

  // cleanup the js <script> libs that are added after the main 'three.js' lib.
  // e.g make it so they're not all on one line.
  // We have to deal with this at the string level (text level) since I don't
  // know how to control formatting at the doc level.
  // Note: string is pass by value, so we get a copy of the text and we can manipulate
  // without altering the original.
  // <script src="../build/three.js"></script><!--vrize add start--><script src="js/vr/WebVR.js"></script><!--vrize add end--><!--vrize add start--><script src="js/vrize/vrize_kbd.js"></script><!--vrize add end-->
  beautifyJsLibChainHtml(text : string) {
    // let newText = text;

    // return newText;
    // text += "hello";
    // identify the "<script src=..three.js>" line.  This will be the long line
    // that has all the concatenated libs
    let regex = /<script\s+src=['"].*three\.js.*/
    let threeJsLibMatch = text.match(regex)

    // if found, pass to beautify
    if (threeJsLibMatch && threeJsLibMatch[0]) {
      let newText = beautify.html(threeJsLibMatch[0]);

      // and then sub it back in
      text = text.replace(regex, newText);
    }

    return text;

  }
开发者ID:vt5491,项目名称:threejs-vr-gallery,代码行数:30,代码来源:transformer.service.ts


示例7: beautifyHtml

export const printPrettyHtml = (html)=> {
  console.log("\n"+ beautifyHtml( html, {"indent_size":2} ).replace(/class=/g, "className=") )
}
开发者ID:Baltox,项目名称:searchkit,代码行数:3,代码来源:TestHelpers.ts



注:本文中的js-beautify.html函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript js-beautify.js_beautify函数代码示例发布时间:2022-05-25
下一篇:
TypeScript js-base64.Base64类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap