Skip to content

Commit e5cd9b6

Browse files
committed
Rename (Tagged → Annotated)String, etc.
In response to further naming discussion. Please, please, let this be the last rename. Along the way we have some docstring improvements and stricter macro construction in the StyledStrings stdlib (erroring on invalid syntax, instead of warning), with more informative messages.
1 parent 9947193 commit e5cd9b6

File tree

19 files changed

+559
-558
lines changed

19 files changed

+559
-558
lines changed

NEWS.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ New language features
88
difference between `public` and `export` is that `public` names do not become
99
available when `using` a package/module. ([#50105])
1010
* `ScopedValue` implement dynamic scope with inheritance across tasks ([#50958]).
11-
* A new `AbstractString` type, `TaggedString`, is introduced that allows for
12-
(arbitrary) regional annotations to be attached to an underlying string. This is
13-
very useful for allowing styling information to be encoded separately, and is
14-
used extensively in the new `StyledStrings` standard library. There is also a
15-
new `TaggedChar` type, that is the equivalent new `AbstractChar` type.
11+
* A new `AbstractString` type, `AnnotatedString`, is introduced that allows for
12+
regional annotations to be attached to an underlying string. This type is
13+
particularly useful for holding styling information, and is used extensively
14+
in the new `StyledStrings` standard library. There is also a new `AnnotatedChar`
15+
type, that is the equivalent new `AbstractChar` type.
1616

1717
Language changes
1818
----------------
@@ -60,11 +60,12 @@ Standard library changes
6060

6161
* A new standard library for handling styling in a more comprehensive and structured way.
6262
* The new `Faces` struct serves as a container for text styling information
63-
(think typeface), and comes with a framework to provide a convenient,
64-
extensible (via `addface!`), and customisable (with a user's `Faces.toml` and `loadfaces!`) approach to
63+
(think typeface, as well as color and decoration), and comes with a framework
64+
to provide a convenient, extensible (via `addface!`), and customisable (with a
65+
user's `Faces.toml` and `loadfaces!`) approach to
6566
styled content.
6667
* The new `@styled_str` string macro provides a convenient way of creating a
67-
`TaggedString` with various faces or other attributes applied.
68+
`AnnotatedString` with various faces or other attributes applied.
6869

6970
#### Package Manager
7071

base/exports.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,12 +1089,12 @@ public
10891089
Generator,
10901090
ImmutableDict,
10911091
OneTo,
1092-
TaggedString,
1093-
TaggedChar,
1092+
AnnotatedString,
1093+
AnnotatedChar,
10941094
UUID,
10951095

1096-
# Tagged strings
1097-
taggedstring,
1096+
# Annotated strings
1097+
annotatedstring,
10981098
annotate!,
10991099
annotations,
11001100

base/regex.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -427,35 +427,35 @@ function match(re::Regex, str::Union{SubString{String}, String}, idx::Integer,
427427
return result
428428
end
429429

430-
function _taggedmatch(m::RegexMatch{S}, str::TaggedString{S}) where {S<:AbstractString}
431-
RegexMatch{TaggedString{S}}(
432-
(@inbounds SubString{TaggedString{S}}(
430+
function _annotatedmatch(m::RegexMatch{S}, str::AnnotatedString{S}) where {S<:AbstractString}
431+
RegexMatch{AnnotatedString{S}}(
432+
(@inbounds SubString{AnnotatedString{S}}(
433433
str, m.match.offset, m.match.ncodeunits, Val(:noshift))),
434-
Union{Nothing,SubString{TaggedString{S}}}[
434+
Union{Nothing,SubString{AnnotatedString{S}}}[
435435
if !isnothing(cap)
436-
(@inbounds SubString{TaggedString{S}}(
436+
(@inbounds SubString{AnnotatedString{S}}(
437437
str, cap.offset, cap.ncodeunits, Val(:noshift)))
438438
end for cap in m.captures],
439439
m.offset, m.offsets, m.regex)
440440
end
441441

442-
function match(re::Regex, str::TaggedString)
442+
function match(re::Regex, str::AnnotatedString)
443443
m = match(re, str.string)
444444
if !isnothing(m)
445-
_taggedmatch(m, str)
445+
_annotatedmatch(m, str)
446446
end
447447
end
448448

449-
function match(re::Regex, str::TaggedString, idx::Integer, add_opts::UInt32=UInt32(0))
449+
function match(re::Regex, str::AnnotatedString, idx::Integer, add_opts::UInt32=UInt32(0))
450450
m = match(re, str.string, idx, add_opts)
451451
if !isnothing(m)
452-
_taggedmatch(m, str)
452+
_annotatedmatch(m, str)
453453
end
454454
end
455455

456456
match(r::Regex, s::AbstractString) = match(r, s, firstindex(s))
457457
match(r::Regex, s::AbstractString, i::Integer) = throw(ArgumentError(
458-
"regex matching is only available for the String and TaggedString types; use String(s) to convert"
458+
"regex matching is only available for the String and AnnotatedString types; use String(s) to convert"
459459
))
460460

461461
findnext(re::Regex, str::Union{String,SubString}, idx::Integer) = _findnext_re(re, str, idx, C_NULL)
@@ -708,8 +708,8 @@ struct RegexMatchIterator{S <: AbstractString}
708708

709709
RegexMatchIterator(regex::Regex, string::AbstractString, ovr::Bool=false) =
710710
new{String}(regex, String(string), ovr)
711-
RegexMatchIterator(regex::Regex, string::TaggedString, ovr::Bool=false) =
712-
new{TaggedString{String}}(regex, TaggedString(String(string.string), string.annotations), ovr)
711+
RegexMatchIterator(regex::Regex, string::AnnotatedString, ovr::Bool=false) =
712+
new{AnnotatedString{String}}(regex, AnnotatedString(String(string.string), string.annotations), ovr)
713713
end
714714
compile(itr::RegexMatchIterator) = (compile(itr.regex); itr)
715715
eltype(::Type{<:RegexMatchIterator}) = RegexMatch

0 commit comments

Comments
 (0)