Skip to content

Commit

Permalink
修改标签匹配方法
Browse files Browse the repository at this point in the history
  • Loading branch information
rztime committed Oct 16, 2023
1 parent e9d9738 commit fd64654
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions RZRichTextView/Classes/RZCss.swift
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,11 @@ public extension NSTextAttachment {
guard let info = self.rzattachmentInfo else { return ""}
switch info.type {
case .audio:
return "<audio src=\"\(info.src ?? "")\" controls=\"controls\" style=\"max-width:100%;\"></audio>"
return "<audio src=\"\(info.src ?? "")\" controls=\"controls\" style=\"max-width:100%;\">您的浏览器不支持此音频格式</audio>"
case .image:
return "<img src=\"\(info.src ?? "")\" style=\"max-width:100%;\">"
case .video:
return "<video src=\"\(info.src ?? "")\" poster=\"\(info.poster ?? "")\" controls=\"controls\" style=\"max-width:100%;\"></video>"
return "<video src=\"\(info.src ?? "")\" poster=\"\(info.poster ?? "")\" controls=\"controls\" style=\"max-width:100%;\">您的浏览器不支持此视频格式</video>"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RZRichTextView/Classes/RZHtml.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public extension String {
var tempHtml = html as NSString
var attachments: [RZAttachmentInfo] = []
/// 找音、视频、图片
let regrule = #"(<video\s+.*?src\s*=\s*([^ <>]+)\b.*?>(.*?)</video>)|(<audio\s+.*?src\s*=\s*([^ <>]+)\b.*?>(.*?)</audio>)|(<img\s+.*?src\s*=\s*([^ <>]+)\b.*?>)"#
let regrule = #"(<video\s+.*?src\s*=\s*([^ <>]+)\b.*?>([\s\S]*?)</video>)|(<audio\s+.*?src\s*=\s*([^ <>]+)\b.*?>([\s\S]*?)</audio>)|(<img\s+.*?src\s*=\s*([^ <>]+)\b.*?>)"#
if let regex = try? NSRegularExpression.init(pattern: regrule, options: .caseInsensitive) {
var labels:[RZLabelInfo] = []
let matches = regex.matches(in: tempHtml as String, range: NSRange.init(location: 0, length: tempHtml.length))
Expand Down

0 comments on commit fd64654

Please sign in to comment.