[英]NSAttributedString from html with blockquote
我知道你在Obj-C中問過這個問題,但我只是點擊了一下,注意到它已經三年沒有答案了,我已經在其他地方完成了這個,所以我不妨分享一下。
let parsedCommentHTML = html.replacingOccurrences(of: "<blockquote>\n", with: "<blockquote>\n<k style=\"color:#ccc; font-size: 2em; font-family: 'Copperplate'\">“</k>")
let blockQuoteCSS = "\nblockquote > p {color:#808080; display: inline;} \n blockquote { background: #f9f9f9;}"
let pCSS = "p {margin-bottom: 0px;}"
let cssStyle = "\(blockQuoteCSS)\n\(pCSS)\n"
return try NSAttributedString(data: ("<html><head><style>\(cssStyle)</style></head><span style=\"font-family: HelveticaNeue-Thin; font-size: 17\">\(parsedCommentHTML)</span></html>").data(using: String.Encoding.unicode)!, options: [NSDocumentTypeDocumentAttribute : NSHTMLTextDocumentType], documentAttributes: nil)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.