mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-26 17:05:19 +01:00
Quote nested <q> tags with alternating quote marks
This commit is contained in:
parent
e6cbdb5d23
commit
7f3b77b760
@ -144,6 +144,7 @@ extension NSAttributedString {
|
|||||||
let result = NSMutableAttributedString()
|
let result = NSMutableAttributedString()
|
||||||
|
|
||||||
var attributeRanges = [ (range: NSRange, styles: CountedSet<Style>) ]()
|
var attributeRanges = [ (range: NSRange, styles: CountedSet<Style>) ]()
|
||||||
|
var quoteDepth = 0
|
||||||
|
|
||||||
while let char = iterator.next() {
|
while let char = iterator.next() {
|
||||||
if char == "<" && inTag == .none {
|
if char == "<" && inTag == .none {
|
||||||
@ -162,7 +163,9 @@ extension NSAttributedString {
|
|||||||
tagStack.append(tag)
|
tagStack.append(tag)
|
||||||
|
|
||||||
if tag == "q" {
|
if tag == "q" {
|
||||||
result.mutableString.append(locale.quotationBeginDelimiter ?? "\"")
|
quoteDepth += 1
|
||||||
|
let delimiter = quoteDepth % 2 == 1 ? locale.quotationBeginDelimiter : locale.alternateQuotationBeginDelimiter
|
||||||
|
result.mutableString.append(delimiter ?? "\"")
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastRange = attributeRanges.last?.range
|
let lastRange = attributeRanges.last?.range
|
||||||
@ -176,11 +179,11 @@ extension NSAttributedString {
|
|||||||
if style != nil {
|
if style != nil {
|
||||||
currentStyles.insert(style!)
|
currentStyles.insert(style!)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if tag == "q" {
|
if tag == "q" {
|
||||||
result.mutableString.append(locale.quotationEndDelimiter ?? "\"")
|
let delimiter = quoteDepth % 2 == 1 ? locale.quotationEndDelimiter : locale.alternateQuotationEndDelimiter
|
||||||
|
result.mutableString.append(delimiter ?? "\"")
|
||||||
|
quoteDepth -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
let lastRange = attributeRanges.last?.range
|
let lastRange = attributeRanges.last?.range
|
||||||
|
Loading…
Reference in New Issue
Block a user