-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to manage default attributes? #13
Comments
One solution is to add default attributes data as parameter to public func process(srcText: String, attrs:[String : AnyObject]) -> NSAttributedString {
...
// we have our patterns, let's build a stylized string
// 1. Apply default attributes
let attributedText = NSMutableAttributedString(string:text, attributes:attrs)
// 2. Add attributes brought by markdown
for pattern in collect {
attributedText.addAttributes(pattern.attrs!, range: NSMakeRange(pattern.start, pattern.length))
}
} |
Sorry, same as #1 |
ghost
closed this as completed
Nov 5, 2015
Oups, closed by mistake. |
ghost
reopened this
Nov 5, 2015
let defaultAttrs = [NSFontAttributeName: UIFont.systemFontOfSize(18)] //default attributes to apply
let attrString = bee.process(rawText,attributes: defaultAttrs) //attributes can be omited if unneeded |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current example transform raw text to
NSAttributedString
for few markdown patters:*?*
_*_
![?](?)
But how to apply default formatting to overall text?
The text was updated successfully, but these errors were encountered: