File tree Expand file tree Collapse file tree 3 files changed +12
-6
lines changed
src/MarkupKit/Core/String Expand file tree Collapse file tree 3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 22
33All notable changes to this project will be documented in this file.
44
5+ ## v1.3.2 - 2025-08-25
6+ - Improved ` AttributedStringBuilder ` by giving it a more fluent interface.
7+
58## v1.3.1 - 2025-08-24
69- Improved usability of ` AttributedStringBuilder ` outside parser context.
710
Original file line number Diff line number Diff line change @@ -44,7 +44,6 @@ public function withAttribute(Attribute $attribute): self
4444
4545 /**
4646 * @param class-string<Attribute>|(Attribute&UnitEnum) $attribute
47- * @return self
4847 */
4948 public function withoutAttribute (string |Attribute $ attribute ): self
5049 {
Original file line number Diff line number Diff line change @@ -107,35 +107,39 @@ private function normalizeTrailingSpace(): array
107107 /**
108108 * @param AttributeContainer|array<int, Attribute> $attributes
109109 */
110- public function appendString (string $ string , AttributeContainer |array $ attributes = []): void
110+ public function appendString (string $ string , AttributeContainer |array $ attributes = []): self
111111 {
112112 $ string = $ this ->normalizeSpace ($ string , end ($ this ->elements ) ?: null );
113113 if (strlen ($ string ) === 0 ) {
114- return ;
114+ return $ this ;
115115 }
116116
117117 $ this ->elements [] = new AttributedSubstring ($ string , $ attributes );
118+ return $ this ;
118119 }
119120
120121 /**
121122 * @param AttributeContainer|array<int, Attribute> $attributes
122123 */
123- public function appendLineBreak (AttributeContainer |array $ attributes = []): void
124+ public function appendLineBreak (AttributeContainer |array $ attributes = []): self
124125 {
125126 $ this ->elements [] = new AttributedSubstring ("\n" , $ attributes );
127+ return $ this ;
126128 }
127129
128- public function appendAttachment (Attachment $ attachment ): void
130+ public function appendAttachment (Attachment $ attachment ): self
129131 {
130132 if (!$ this ->trimWhitespaceAroundAttachments ) {
131133 $ this ->elements [] = $ attachment ;
132- return ;
134+ return $ this ;
133135 }
134136
135137 $ this ->elements = [
136138 ...$ this ->normalizeTrailingSpace (),
137139 $ attachment
138140 ];
141+
142+ return $ this ;
139143 }
140144
141145 public function isEmpty (): bool
You can’t perform that action at this time.
0 commit comments