Skip to content

Commit ccf8067

Browse files
author
Sourcery AI
committed
'Refactored by Sourcery'
1 parent a23c122 commit ccf8067

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

discord_markdown_ast_parser/parser.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def parse_tokens_generator(
248248
)
249249
i += 1
250250
continue
251-
251+
252252
# URL with preview
253253
if LexingRule.URL_WITH_PREVIEW in current_token:
254254
yield Node(
@@ -316,21 +316,14 @@ def parse_tokens_generator(
316316
tokens[i + 1 :], [current_token.lexing_rule]
317317
)
318318
if children_token is not None:
319-
children_content = ""
320-
# treat all children token as inline text
321-
for child_token in children_token:
322-
children_content += child_token.value
323-
319+
children_content = "".join(child_token.value for child_token in children_token)
324320
# check for a language specifier
325321
lines = children_content.split("\n")
326-
# there must be at least one other non-empty line
327-
# (the content doesn't matter, there just has to be one)
328-
non_empty_line_found = False
329322
lang = None
330-
for line_index in range(1, len(lines)):
331-
if len(lines[line_index]) > 0:
332-
non_empty_line_found = True
333-
break
323+
non_empty_line_found = any(
324+
len(lines[line_index]) > 0
325+
for line_index in range(1, len(lines))
326+
)
334327
if non_empty_line_found:
335328
match = LANG_SPEC.fullmatch(lines[0])
336329
# if there is any behind the lang spec, then it is normal text
@@ -382,7 +375,7 @@ def parse_tokens_generator(
382375
i = len(tokens) # move to the end
383376
break
384377

385-
if len(children_token_in_quote_block) > 0:
378+
if children_token_in_quote_block:
386379
# tell the inner parse function that it's now inside a quote block
387380
children_nodes = list(
388381
parse_tokens_generator(

0 commit comments

Comments
 (0)