@@ -831,7 +831,7 @@ def fixup_chunks(chunks, comparator):
831
831
832
832
elif current_token == TokenType .href :
833
833
href = chunk [1 ]
834
- cur_word = href_token (href , comparator = comparator , pre_tags = tag_accum , trailing_whitespace = " " )
834
+ cur_word = MinimalHrefToken (href , comparator = comparator , pre_tags = tag_accum , trailing_whitespace = " " )
835
835
tag_accum = []
836
836
result .append (cur_word )
837
837
@@ -1112,20 +1112,19 @@ def _customize_tokens(tokens):
1112
1112
# result.append(SpacerToken(SPACER_STRING))
1113
1113
# result.append(SpacerToken(SPACER_STRING))
1114
1114
1115
- customized = _customize_token (token )
1116
- result .append (customized )
1115
+ result .append (token )
1117
1116
1118
- if str (customized ) == "Posts" and str (tokens [token_index - 1 ]) == 'Other' and str (tokens [token_index - 2 ]) == 'and' : # and str(tokens[token_index - 3]) == 'posts':
1117
+ if str (token ) == "Posts" and str (tokens [token_index - 1 ]) == 'Other' and str (tokens [token_index - 2 ]) == 'and' : # and str(tokens[token_index - 3]) == 'posts':
1119
1118
logger .debug (f'SPECIAL TAG!\n pre: { token .pre_tags } \n token: "{ token } "\n post: { token .post_tags } ' )
1120
1119
next_token = tokens [token_index + 1 ]
1121
1120
logger .debug (f'SPECIAL TAG!\n pre: { next_token .pre_tags } \n token: "{ next_token } "\n post: { next_token .post_tags } ' )
1122
- for tag_index , tag in enumerate (customized .post_tags ):
1121
+ for tag_index , tag in enumerate (token .post_tags ):
1123
1122
if tag .startswith ('</ul>' ):
1124
1123
new_token = SpacerToken (SPACER_STRING )
1125
1124
result .append (new_token )
1126
- new_token = SpacerToken (SPACER_STRING , pre_tags = customized .post_tags [tag_index :])
1125
+ new_token = SpacerToken (SPACER_STRING , pre_tags = token .post_tags [tag_index :])
1127
1126
result .append (new_token )
1128
- customized .post_tags = customized .post_tags [:tag_index ]
1127
+ token .post_tags = token .post_tags [:tag_index ]
1129
1128
1130
1129
# if isinstance(customized, ImgTagToken):
1131
1130
# result.append(SpacerToken(SPACER_STRING))
@@ -1143,7 +1142,7 @@ def _customize_tokens(tokens):
1143
1142
# # result.append(SpacerToken(SPACER_STRING, post_tags=customized.post_tags, trailing_whitespace=customized.trailing_whitespace))
1144
1143
# customized.post_tags = []
1145
1144
# # customized.trailing_whitespace = ''
1146
- for tag_index , tag in enumerate (customized .post_tags ):
1145
+ for tag_index , tag in enumerate (token .post_tags ):
1147
1146
split_here = False
1148
1147
for name in SEPARATABLE_TAGS :
1149
1148
if tag .startswith (f'<{ name } ' ):
@@ -1156,8 +1155,8 @@ def _customize_tokens(tokens):
1156
1155
# new_token = SpacerToken(SPACER_STRING, pre_tags=customized.post_tags[tag_index:])
1157
1156
# customized.post_tags = customized.post_tags[0:tag_index]
1158
1157
1159
- new_token = SpacerToken (SPACER_STRING , post_tags = customized .post_tags [tag_index :])
1160
- customized .post_tags = customized .post_tags [0 :tag_index ]
1158
+ new_token = SpacerToken (SPACER_STRING , post_tags = token .post_tags [tag_index :])
1159
+ token .post_tags = token .post_tags [0 :tag_index ]
1161
1160
1162
1161
# tokens.insert(token_index + 1, token)
1163
1162
# token = new_token
@@ -1193,25 +1192,6 @@ def _has_heading_tags(tag_list):
1193
1192
return True
1194
1193
1195
1194
1196
- # Seemed so nice and clean! But should probably be merged into
1197
- # `_customize_tokens()` now. Or otherwise it needs to be able to produce more
1198
- # than one token to replace the given token in the stream.
1199
- def _customize_token (token ):
1200
- """
1201
- Replace existing diffing tokens with customized ones for better output.
1202
- """
1203
- if isinstance (token , href_token ):
1204
- return MinimalHrefToken (
1205
- str (token ),
1206
- comparator = token .comparator ,
1207
- pre_tags = token .pre_tags ,
1208
- post_tags = token .post_tags ,
1209
- trailing_whitespace = token .trailing_whitespace )
1210
- # return token
1211
- else :
1212
- return token
1213
-
1214
-
1215
1195
# TODO: merge and reconcile this with `merge_change_groups()`, which is 90%
1216
1196
# the same thing; it outputs the change elements as nested lists of tokens.
1217
1197
def merge_changes (change_chunks , doc , tag_type = 'ins' ):
0 commit comments