diff --git a/Shared/Extensions/NSAttributedString+NetNewsWire.swift b/Shared/Extensions/NSAttributedString+NetNewsWire.swift index bb2cc2821..56eb7b30c 100644 --- a/Shared/Extensions/NSAttributedString+NetNewsWire.swift +++ b/Shared/Extensions/NSAttributedString+NetNewsWire.swift @@ -159,6 +159,12 @@ extension NSAttributedString { tag.append(first) } } else if char == ">" && inTag != .none { + let lastRange = attributeRanges.last?.range + let location = lastRange != nil ? lastRange!.location + lastRange!.length : 0 + let range = NSRange(location: location, length: result.mutableString.length - location) + + attributeRanges.append( (range: range, styles: currentStyles) ) + if inTag == .opening { tagStack.append(tag) @@ -168,12 +174,6 @@ extension NSAttributedString { result.mutableString.append(delimiter ?? "\"") } - let lastRange = attributeRanges.last?.range - let location = lastRange != nil ? lastRange!.location + lastRange!.length : 0 - let range = NSRange(location: location, length: result.mutableString.length - location) - - attributeRanges.append( (range: range, styles: currentStyles) ) - if let style = Style(tag: tag) { currentStyles.insert(style) } @@ -184,12 +184,6 @@ extension NSAttributedString { quoteDepth -= 1 } - let lastRange = attributeRanges.last?.range - let location = lastRange != nil ? lastRange!.location + lastRange!.length : 0 - let range = NSRange(location: location, length: result.mutableString.length - location) - - attributeRanges.append( ( range: range, styles: currentStyles )) - if let style = Style(tag: tag) { currentStyles.remove(style) }