|
@@ -57,11 +57,27 @@ namespace GxPress.Service.Implement.Epub
|
|
|
if (textContentFile.FileName.Equals(request.CatalogId) || textContentFile.FileName.Equals(request.CatalogNameg))
|
|
|
{
|
|
|
//当前文本内容文件的HTML
|
|
|
- htmlContent = textContentFile.Content;
|
|
|
+ htmlContent = ReplaceHtmlTag(textContentFile.Content);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
return htmlContent;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// C#去除HTML标签
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="html">带有html标签的文本</param>
|
|
|
+ /// <param name="length">截取长度</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public string ReplaceHtmlTag(string html, int length = 0)
|
|
|
+ {
|
|
|
+ string strText = System.Text.RegularExpressions.Regex.Replace(html, "<[^>]+>", "");
|
|
|
+ strText = System.Text.RegularExpressions.Regex.Replace(strText, "&[^;]+;", "");
|
|
|
+
|
|
|
+ if (length > 0 && strText.Length > length)
|
|
|
+ return strText.Substring(0, length);
|
|
|
+
|
|
|
+ return strText;
|
|
|
+ }
|
|
|
}
|
|
|
}
|