Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno Muniz Azevedo Filho committed Oct 26, 2023
1 parent f63377d commit f00a9d0
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# MultiAttributedString

`MultiAttributedString` allows you to create `NSAttributedString` with multiple text attributes applied to different parts of a string based on user-defined symbol delimiters.
`MultiAttributedString` provides a convenient way to generate `NSAttributedString` with varying text attributes for different sections of a string, based on user-defined symbol delimiters.

## Features

- [x] Apply different text attributes (such as font, color, link, etc.) to specific portions of a string.
- [x] Define custom symbol delimiters to specify where attributes should be applied.
- [ ] Handle escaped symbols to treat them as literals and not as attribute delimiters.
- [ ] Support nested symbol pairs, with innermost symbols taking precedence.
- [x] Easily apply varied text attributes (e.g., font, color, links) to distinct parts of a string.
- [x] Use custom symbol delimiters to dictate where attributes should be applied in the string.
- [ ] Support for escaped symbols, allowing them to be interpreted as regular characters instead of attribute delimiters.
- [ ] Capability to handle nested symbol pairs, with attributes from the innermost symbols given priority.

## Usage

### Installation

You can add `MultiAttributedString` to your project using Swift Package Manager (SPM):
To integrate `MultiAttributedString` into your project, use the Swift Package Manager (SPM):

1. In Xcode, go to "File" > "Swift Packages" > "Add Package Dependency..."
2. Enter `https://github.com/brunomunizaf/MultiAttributedString.git`
Expand All @@ -26,17 +26,17 @@ Here's a basic example of how to use `MultiAttributedString`:
```swift
import MultiAttributedString

let pairs = [
AttributeSymbolPair(attributes: [.foregroundColor: UIColor.red], symbol: "$"),
AttributeSymbolPair(attributes: [.foregroundColor: UIColor.blue], symbol: "#")
]

let attributedString = NSAttributedString.with("This is $red$ and this is #blue# text.", attributesBetween: pairs)
let attributedString = "This is $red$ text, and this is #blue small# text".applying(
attributes: [
"$": [.foregroundColor: UIColor.red],
"#": [.foregroundColor: UIColor.blue, .font: UIFont.systemFont(withSize: 10.0)]
]
)
```

In this example, we define symbol pairs (e.g., `$` and `#`) with associated attributes. Then, we create an attributed string using the `NSAttributedString.with(_:attributesBetween:)` method, specifying the input string and the symbol pairs.
In this example, we define symbol pairs (e.g., `$` and `#`) with associated attributes. Then, we create an attributed string using the `.applying(attributes:)` method.

### Escaping Symbols
### Escaping Symbols (In progress ⏳)

You can use the backslash (`\`) as an escape character to treat symbols as literals. For example:

Expand Down

0 comments on commit f00a9d0

Please sign in to comment.