You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+57-46Lines changed: 57 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,14 @@
4
4
</p>
5
5
<br>
6
6
7
-
`Atributika` is an easy and painless way to build NSAttributedString. It is able to detect HTML-like tags, links, phone numbers, hashtags, any regex or even standard ios data detectors and style them with various attributes like font, color, etc. `Atributika` comes with drop-in label replacement `AttributedLabel` which is able to make any detection clickable
8
7
9
-
## Intro
10
-
NSAttributedString is really powerful but still a low level API which requires a lot of work to setup things. It is especially painful if string is template and real content is known only in runtime. If you are dealing with localizations, it is also not easy to build NSAttributedString.
8
+
`Atributika` is a Swift library that provides a simple way to build NSAttributedString from HTML-like text, by identifying and styling tags, links, phone numbers, hashtags, and so on.
9
+
A standalone `AtributikaViews` library offers UILabel/UITextView drop-in replacements capable of displaying highlightable and clickable links, rich customization, and solid accessibility support.
11
10
12
-
Oh wait, but you can use Atributika!
11
+
## Introduction
12
+
While NSAttributedString is undoubtedly powerful, it's also a low-level API that demands a considerable amount of setup work. If your string is a template and the actual content is only known at runtime, this becomes particularly tedious. When dealing with localizations, constructing NSAttributedString isn't straightforward either.
13
+
14
+
But wait, `Atributika` comes to your rescue!
13
15
14
16
```swift
15
17
let b = Attrs.font(.boldSystemFont(ofSize: 20)).foregroundColor(.red)
Yeah, that's much better. Atributika is easy, declarative, flexible and covers all the raw edges for you.
24
+
Indeed, that's much simpler. `Atributika` is easy-to-use, declarative, flexible, and handles the rough edges for you.
23
25
24
26
25
27
## Features
26
28
27
-
+ AttributedLabel` is a drop-in label replacement which **makes detections clickable** and style them dynamically for `normal/highlighted/disabled` states.
28
-
+detect and style HTML-like **tags** using custom speedy parser
29
-
+detect and style **hashtags** and **mentions**(i.e. #something and @someone)
30
-
+detect and style**links** and **phone numbers**
31
-
+detect and style regex and NSDataDetector patterns
32
-
+style whole string or just particular ranges
33
-
+... and you can chain all above to parse some uber strings!
34
-
+clean and expressive api to build styles
35
-
+separate set of detection utils, in case you want to use just them
36
-
+`+` operator to concatenate NSAttributedString with other attributed or regular strings
37
-
+works on iOS, tvOS, watchOS, macOS
29
+
Atributika
30
+
+NSAttributedString builder.
31
+
+Detects and styles HTML-like **tags**using a custom high-speed parser.
32
+
+Detects and styles**hashtags** and **mentions** (i.e., #something and @someone).
33
+
+Identifies and styles **links** and **phone numbers**.
34
+
+Detects and styles regexes and NSDataDetector patterns.
35
+
+Styles the entire string or just specified ranges.
36
+
+Allows all the above to be chained together to parse complex strings!
37
+
+Provides a clean and expressive API to construct styles.
38
+
+Offers a separate set of detection utilities for standalone use.
39
+
+Compatible with iOS, tvOS, watchOS, and macOS.
38
40
39
-
## V5
41
+
AtributikaViews
42
+
+ Custom views with **highlightable and clickable** links.
43
+
+ Custom text styles for `normal/highlighted/disabled` states.
44
+
+ Supports custom highlighting.
40
45
41
-
V5 is a major rewrite of the project happened at Spring 2023
46
+
## Version 5
42
47
43
-
NSAttributedString building
44
-
+ HTML parser completely rewritten, supports more edge cases
45
-
+ Text transforming and attributes fine tuning depening from detected text
48
+
Version 5 is a significant rewrite of the project, executed in early 2023. It's not fully compatible with the previous version and requires some manual migration. The introduction of breaking changes was necessary for the project's further evolution.
46
49
47
-
AttributedLabel / AttributedTextView
48
-
+ proper accessibility support
49
-
+ doesn't depend from the string building code and classes
50
-
+ better performance and touch handling
51
-
+ subclass off UIControl
52
-
+ AttributedLabel based on UILabel (more lightweight, text is centered vertically), AttributedTextView based on UITextView (supports scrolling and text selections, text is aligned to the top of the frame)
50
+
Here's what's new:
53
51
54
-
`Style("xxx").`/`Style.` -> `Attr.`
55
-
`styleAll` -> `styleBase`
52
+
NSAttributedString Building
53
+
+ Completely rewritten HTML parser, which fixed a multitude of bugs and improved handling of edge cases.
54
+
+ More generic and robust Text transforming and attribute fine-tuning APIs.
56
55
57
-
AttributedLabel api is reworked a lot see updated example below
56
+
AttributedLabel / AttributedTextView
57
+
+ Moved to a standalone library, independent of Atributika.
58
+
+ Offers proper accessibility support.
59
+
+ Reworked API for improved performance and touch handling.
60
+
+ AttributedLabel is based on UILabel (lightweight, with vertically-centered text).
61
+
+ AttributedTextView is based on UITextView (supports scrolling and text selection, with text aligned to the top of the frame).
58
62
63
+
New examples have been added to the Demo application, including:
64
+
+ Basic web browser powered by Atributika
65
+
+ SwiftUI integration
66
+
+ Highlightable links for Markdown documents
59
67
60
68
## Examples
61
69
@@ -152,25 +160,27 @@ let str = "Call me (888)555-5512"
let tweet ="@all I found <u>really</u> nice framework to manage attributed strings. It is called <b>Atributika</b>. Call me if you want to know more (123)456-7890 #swift #nsattributedstring https://github.com/psharanda/Atributika"
183
+
let tweet ="@all I found <u>really</u> nice framework to manage attributed strings. It is called <b>Atributika</b>. Call me if you want to know more (123)456-7890 #swift #nsattributedstring https://github.com/psharanda/Atributika"
0 commit comments