Skip to content

Commit

Permalink
fixes 102
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanomondino committed Jan 26, 2020
1 parent f08bca2 commit 494cd13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
5 changes: 3 additions & 2 deletions ExampleiOS/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ class ViewController: UIViewController {
fatalError()
}

self.textView?.attributedText = text.set(style: xmlStyle)
// self.textView?.attributedText = text.set(style: xmlStyle)

return
// return

// self.textView?.attributedText = "ciao ciao " + AttributedString(image: UIImage(named: "rocket")!,
// bounds: CGRect(x: 0, y: -20, width: 25, height: 25)) + "ciao ciao"
Expand Down Expand Up @@ -85,6 +85,7 @@ class ViewController: UIViewController {
"b": boldStyle,
"em": italicStyle,
"i": italicStyle,
"a": uppercasedRed,
"li": Style {
$0.paragraphSpacingBefore = self.baseFontSize / 2
$0.firstLineHeadIndent = self.baseFontSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,21 @@ extension XMLDynamicAttributesResolver {

open class StandardXMLAttributesResolver: XMLDynamicAttributesResolver {

public func applyDynamicAttributes(to attributedString: inout AttributedString, xmlStyle: XMLDynamicStyle, fromStyle: StyleXML) {
open func applyDynamicAttributes(to attributedString: inout AttributedString, xmlStyle: XMLDynamicStyle, fromStyle: StyleXML) {
let finalStyleToApply = Style()
xmlStyle.enumerateAttributes { key, value in
switch key {
case "color": // color support
finalStyleToApply.color = Color(hexString: value)

default:
break
default: break
}
}

self.styleForUnknownXMLTag(xmlStyle.tag, to: &attributedString, attributes: xmlStyle.xmlAttributes, fromStyle: fromStyle)
attributedString.add(style: finalStyleToApply)
}

public func styleForUnknownXMLTag(_ tag: String, to attributedString: inout AttributedString, attributes: [String: String]?, fromStyle: StyleXML) {
open func styleForUnknownXMLTag(_ tag: String, to attributedString: inout AttributedString, attributes: [String: String]?, fromStyle: StyleXML) {
let finalStyleToApply = Style()
switch tag {
case "a": // href support
Expand Down

0 comments on commit 494cd13

Please sign in to comment.