本文整理汇总了C#中CsQuery.CQ.Parent方法的典型用法代码示例。如果您正苦于以下问题:C# CQ.Parent方法的具体用法?C# CQ.Parent怎么用?C# CQ.Parent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CsQuery.CQ
的用法示例。
在下文中一共展示了CQ.Parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareHtml
private string PrepareHtml(string html)
{
// Make title
if (!Notitle)
{
html = "<h2>" + Title + "</h2>" + html;
}
html = "<span class=\"invisible chapterstart\">" + (Noheader ? "" : Title) + "</span>" + html;
// Make sure page break is set
if (Pagebreak)
{
html = "<span class=\"invisible pagebreak\"></span>" + html;
}
CQ dom = CQ.CreateFragment("<div class=\"content\">" + html + "</div>");
// Remove next/prev table
dom.Find("table:contains('Forward'):contains('Back')").Last().Remove();
// Find images
foreach(IDomElement aNode in dom.Find("a.image")) {
var a = new CQ(aNode);
var img = new CQ(a.Find("img"));
var src = img.Attr("src").Replace("/thumb", "");
src = Regex.Replace(src, @"[.](jpg|png|gif)\/.+$", @".$1", RegexOptions.IgnoreCase);
var image = new Image(src, new Uri(Wiki)) {Sashie = true};
CQ node = a.Closest(".thumb").Add(a).First();
if (_images.Count == 0 && EntryPicture)
{
// We can view it as a full-fledged image since we don't need to worry about text-flow
image.Sashie = false;
dom.Before(image.Html);
}
else
{
node.Before(image.Html);
//node.After("<span class=\"image-stopper\"></span>");
}
node.Remove();
_images.Add(image);
}
// Catch references
foreach (IDomElement supNode in dom.Find("sup.reference"))
{
var sup = new CQ(supNode);
CQ footnote = "<span class=\"fn\"></span>";
CQ oldFootnote = dom.Find("#" + sup.Attr("id").Replace("_ref-", "_note-"));
footnote.Html(oldFootnote.Find(".reference-text").Html());
oldFootnote.Remove();
sup.Before(footnote).Remove();
}
// Remove possible reference title
dom.Find(".references").Prev(":header").Remove();
// Remove edit links
dom.Find(".editsection, #toc").Remove();
// Make smart quotes
dom.Find("p:contains('\"'), p:contains(\"'\"), li:contains('\"'), li:contains(\"'\")").Each((el) =>
{
CQ p = new CQ(el);
string pHtml = p.Html();
// Replace quotes
if (Regex.Matches(pHtml, """).Count % 2 == 0)
{
pHtml = Regex.Replace(pHtml, ""(.+?)"", "“$1”");
}
else
{
Console.WriteLine("NOTICE: possible quotes problem ({0})", pHtml.Trim());
}
// Replace single quotes (\b doesn't work)
pHtml = Regex.Replace(pHtml, "(?<!\\w)'(.+?)'(?!\\w)", "‘$1’");
// Replace apostrophes
pHtml = Regex.Replace(pHtml, "'", "’");
p.Html(pHtml);
});
// Parse Ruby
dom.Find("span > span > span").Each(el =>
{
var rubySpan = new CQ(el);
if(rubySpan.Css("position") == "relative" && rubySpan.Css("left") == "-50%") {
var textSpan = rubySpan.Parent().Siblings("span");
var containerSpan = textSpan.Parent();
if (textSpan.Length == 1 && containerSpan.Css("white-space") == "nowrap")
//.........这里部分代码省略.........