···
feature_type = feature['$type']
37
-
if feature_type == 'app.bsky.richtext.facet#tag':
38
-
slices.append((index['byteStart'], index['byteEnd'], 'tag', feature['tag']))
39
-
elif feature_type == 'app.bsky.richtext.facet#link':
40
-
slices.append((index['byteStart'], index['byteEnd'], 'link', feature['uri']))
41
-
elif feature_type == 'app.bsky.richtext.facet#mention':
42
-
slices.append((index['byteStart'], index['byteEnd'], 'mention', feature['did']))
38
+
case 'app.bsky.richtext.facet#tag':
39
+
slices.append((index['byteStart'], index['byteEnd'], 'tag', feature['tag']))
40
+
case 'app.bsky.richtext.facet#link':
41
+
slices.append((index['byteStart'], index['byteEnd'], 'link', feature['uri']))
42
+
case 'app.bsky.richtext.facet#mention':
43
+
slices.append((index['byteStart'], index['byteEnd'], 'mention', feature['did']))
return [cross.TextToken(text)]
···
tokens.append(cross.TextToken(text[prev:start]))
67
-
label = text[start:end]
69
+
label = text[start:end]
69
-
# try to unflatten links
70
-
split = val.split('://')
72
-
if split[1].startswith(label):
73
-
tokens.append(cross.LinkToken(val, ''))
74
-
elif label.endswith('...') and split[1].startswith(label[:-3]):
75
-
tokens.append(cross.LinkToken(val, ''))
77
-
tokens.append(cross.LinkToken(val, label))
78
-
elif ttype == 'tag':
79
-
tokens.append(cross.TagToken(text[start:end]))
80
-
elif ttype == 'mention':
81
-
tokens.append(cross.MentionToken(text[start:end], val))
71
+
# try to unflatten links
72
+
split = val.split('://')
74
+
if split[1].startswith(label):
75
+
tokens.append(cross.LinkToken(val, ''))
76
+
elif label.endswith('...') and split[1].startswith(label[:-3]):
77
+
tokens.append(cross.LinkToken(val, ''))
79
+
tokens.append(cross.LinkToken(val, label))
81
+
tokens.append(cross.TagToken(text[start:end]))
83
+
tokens.append(cross.MentionToken(text[start:end], val))