本文整理汇总了C#中CsQuery.CQ.ReplaceWith方法的典型用法代码示例。如果您正苦于以下问题:C# CQ.ReplaceWith方法的具体用法?C# CQ.ReplaceWith怎么用?C# CQ.ReplaceWith使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsQuery.CQ
的用法示例。
在下文中一共展示了CQ.ReplaceWith方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ToTomboyXml
public static string ToTomboyXml(this string html_body)
{
var body = html_body.Replace ("<br>", "\n");
CQ html = body;
html["b"].ReplaceOuterWithTag("<bold/>");
html["i"].ReplaceOuterWithTag ("<i/>");
html["ul"].ReplaceOuterWithTag ("<list/>");
html["li"].ReplaceOuterWithTag ("<list-item />");
html["h1"].ReplaceOuterWithTag ("<size:huge/>");
html["h2"].ReplaceOuterWithTag ("<size:large/>");
html["small"].ReplaceOuterWithTag ("<size:small/>");
html["strike"].ReplaceOuterWithTag ("<strikethrough/>");
html["pre"].ReplaceOuterWithTag ("<monospace/>");
html["a[class='internal']"].ReplaceOuterWithTag ("<link:internal/>");
html["a[class='url']"].ReplaceOuterWithTag ("<link:url/>");
html["a"].ReplaceOuterWithTag ("<link:url/>");
html["span[class='highlight']"].ReplaceOuterWithTag ("<highlight/>");
// hack replace <div> which get inserted by the wysihtml5
html["div"].Each (domobj => {
CQ e = new CQ (domobj);
var all = new CQ(e.Html());
e.ReplaceWith(all);
});
var render = html.Render ();
// maybe bug int tomboy - </list-items> need a single \n in from of them
render = Regex.Replace (render, @"(?!\n)</list-item>", "\n</list-item>", RegexOptions.ExplicitCapture);
return render;
}