我想格式化HTML ..我用tidymanaged
像格式的HTML文件
<html>
<link rel='stylesheet' type='text/css' href='/lib/styles/default/general_app.css'></link>
<title>test</title>
<body>asd<input type='text' />
</body>
</html>
TIDYMANAGED
using (Document doc = Document.FromString(newFile))
{
doc.ShowWarnings = false;
doc.Quiet = true;
doc.DocType = TidyManaged.DocTypeMode.Strict;
doc.DropFontTags = true;
doc.UseLogicalEmphasis = true;
doc.OutputXhtml = false;
doc.OutputXml = false;
doc.MakeClean = true;
doc.DropEmptyParagraphs = true;
doc.CleanWord2000 = true;
doc.QuoteAmpersands = true;
doc.JoinStyles = false;
doc.JoinClasses = false;
doc.Markup = true;
doc.IndentSpaces = 4;
doc.IndentBlockElements = TidyManaged.AutoBool.Yes;
doc.CharacterEncoding = TidyManaged.EncodingType.Utf8;
doc.CleanAndRepair();
parsed = doc.Save();
}
尝试,但它从输入标签去掉斜线和节目,如<link />
其中的链接标签我想`
然后我试了prettydiff
那就是http://prettydiff.com/
var str = "<html><body><h1>hello</h1></body><html>";
// Options can be viewed at:
// http://prettydiff.com/documentation.xhtml#function_properties
var options = {
source: str,
mode: "beautify", // beautify, diff, minify, parse
lang: "html",
wrap: 100,
inchar: "\t", // indent character
insize: 1 // number of indent characters per indent
}
var pd = prettydiff(options); // returns and array: [beautified, report]
var pretty = pd[0];
console.log(pretty);
var report = pd[1];
console.log(report);
,但它不工作even..can有人给我一些suggesion请该如何解决呢?
看看中的jsfiddle开发者控制台,有错误,告诉你,你不能加载在“HTTP”协议外的.js。只需将外部资源的链接地址从“http:// examle.com”更改为“https:// example.com”即可。 – Buksy
@Buksy更新了问题..https://没有解决问题,因此我添加了它to javascript directly..please check and tell me suggestion – Dhara