/// <summary> /// 添加目录页面。 /// </summary> public void AddToc() { var builder = new StringBuilder(); builder.AppendFormat("<h1>目录</h1>"); builder.Append("<ul>"); var manifests = Manifest.Where(x => x.IsSpine && !x.IsCover && !x.IsToc).OrderBy(x => x.Id).ToList(); foreach (var manifest in manifests) { builder.AppendFormat("<li class=\"chapter\"><a href=\"{0}\">{1}</a></li>", manifest.Href, manifest.Title); } builder.Append("</ul>"); AddHtml(EpubSettings.TocFile, builder.ToString(), "目录"); var current = GetOrCreate(EpubSettings.TocFile); current.IsSpine = true; current.Title = "目录"; current.IsToc = true; Create($"{current.Href}", EpubSettings.Html(current.Title, builder.ToString())); Save(); }
/// <summary> /// 添加默认模板内容。 /// </summary> /// <param name="fileName">文件名。</param> /// <param name="content">内容。</param> /// <param name="title">标题。</param> public Task AddHtmlAsync(string fileName, string content, string title) { content = $"<h2><span style=\"border-bottom:1px solid\">正文 {title}</span></h2>" + content; content = EpubSettings.Html(title, content); return(AddContentAsync(fileName, content, title)); }
/// <summary> /// 添加默认模板内容。 /// </summary> /// <param name="fileName">文件名。</param> /// <param name="content">内容。</param> /// <param name="title">标题。</param> public void AddHtml(string fileName, string content, string title) { content = $"<h2><span style=\"border-bottom:1px solid\">正文 {title}</span></h2>" + content; content = EpubSettings.Html(title, content); AddContent(fileName, content, title); }