Skip to content

Commit b8086ba

Browse files
authored
Merge pull request #65 from ZhgChgLi/fix/harry/list-item-and-stripper-bug-fix
Fix/harry/list item and stripper bug fix
2 parents ba02833 + 39531f5 commit b8086ba

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Sources/ZMarkupParser/HTML/Processor/HTMLElementMarkupComponentMarkupStyleVisitor.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,19 +82,20 @@ struct HTMLElementMarkupComponentMarkupStyleVisitor: MarkupVisitor {
8282
let indent = (style.font.size ?? 16) * markup.styleList.indentMultiply
8383
let dotIndent: CGFloat = (markup.styleList.type.isOrder()) ? (indent) : (0) // for 1. -> "."
8484

85+
// Find Parent Indent if exists.
8586
var parentIndent: CGFloat = 0
8687
var parentMarkup: Markup? = markup.parentMarkup
8788
while (parentMarkup != nil) {
8889
if let thisParentMarkup = parentMarkup as? ListMarkup {
89-
parentIndent += visit(markup: thisParentMarkup)?.paragraphStyle.headIndent ?? 0
90+
parentIndent = visit(markup: thisParentMarkup)?.paragraphStyle.headIndent ?? 0
91+
break
9092
}
9193
parentMarkup = parentMarkup?.parentMarkup
9294
}
9395

9496
var tabStops: [NSTextTab] = [.init(textAlignment: .left, location: headIndent + parentIndent)]
9597
tabStops.append(.init(textAlignment: .left, location: headIndent + parentIndent + dotIndent + indent))
9698

97-
9899
style.paragraphStyle.tabStops = style.paragraphStyle.tabStops ?? tabStops
99100
style.paragraphStyle.headIndent = style.paragraphStyle.headIndent ?? style.paragraphStyle.tabStops?.last?.location
100101
return style

Sources/ZMarkupParser/HTML/ZHTMLParser.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,12 @@ public final class ZHTMLParser {
9696
}
9797

9898
public func stripper(_ attributedString: NSAttributedString) -> NSAttributedString {
99-
let items = process(attributedString)
99+
let stripedAttributedString = decodeHTMLEntities(attributedString)
100+
let items = process(stripedAttributedString)
100101
let reuslt = htmlParsedResultToHTMLElementWithRootMarkupProcessor.process(from: items)
101-
let attributedString = markupStripperProcessor.process(from: reuslt.markup)
102+
let resultAttributedString = markupStripperProcessor.process(from: reuslt.markup)
102103

103-
return attributedString
104+
return resultAttributedString
104105
}
105106

106107
//

0 commit comments

Comments
 (0)