Skip to content

Conversation

@sourcery-ai
Copy link

@sourcery-ai sourcery-ai bot commented Feb 17, 2022

Branch xin refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the xin branch, then run:

git fetch origin sourcery/xin
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from xinetzone February 17, 2022 00:24
Comment on lines -125 to +127
rules = component.get("rules", None)
if rules:
if rules := component.get("rules", None):
self[name].ruler.enableOnly(rules)
rules2 = component.get("rules2", None)
if rules2:
if rules2 := component.get("rules2", None):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MarkdownIt.configure refactored with the following changes:

Comment on lines -108 to +113
result = ""

for i, token in enumerate(tokens):
if token.type in self.rules:
result += self.rules[token.type](tokens, i, options, env)
else:
result += self.renderToken(tokens, i, options, env)

return result
return "".join(
self.rules[token.type](tokens, i, options, env)
if token.type in self.rules
else self.renderToken(tokens, i, options, env)
for i, token in enumerate(tokens)
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RendererHTML.renderInline refactored with the following changes:

Comment on lines -164 to +172
if token.nesting == 1:
if idx + 1 < len(tokens):
nextToken = tokens[idx + 1]
if token.nesting == 1 and idx + 1 < len(tokens):
nextToken = tokens[idx + 1]

if nextToken.type == "inline" or nextToken.hidden:
# Block-level tag containing an inline tag.
#
needLf = False
if nextToken.type == "inline" or nextToken.hidden:
# Block-level tag containing an inline tag.
#
needLf = False

elif nextToken.nesting == -1 and nextToken.tag == token.tag:
# Opening tag + closing tag of the same type. E.g. `<li></li>`.
#
needLf = False
elif nextToken.nesting == -1 and nextToken.tag == token.tag:
# Opening tag + closing tag of the same type. E.g. `<li></li>`.
#
needLf = False
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RendererHTML.renderToken refactored with the following changes:

Comment on lines -185 to +184
result = ""

for key, value in token.attrItems():
result += " " + escapeHtml(key) + '="' + escapeHtml(str(value)) + '"'

return result
return "".join(
f' {escapeHtml(key)}' + '="' + escapeHtml(str(value)) + '"'
for key, value in token.attrItems()
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RendererHTML.renderAttrs refactored with the following changes:

Comment on lines -224 to +220
return (
"<code"
return (("<code"
+ self.renderAttrs(token)
+ ">"
+ escapeHtml(tokens[idx].content)
+ "</code>"
)
+ ">" + escapeHtml(token.content)) + "</code>")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function RendererHTML.code_inline refactored with the following changes:

Comment on lines -79 to +76
if scheme in RECODE_HOSTNAME_FOR:
url = urlunparse(
return urlunparse(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function normalizeLink refactored with the following changes:

Comment on lines -129 to +121
if scheme in RECODE_HOSTNAME_FOR:
url = urlunparse(
return urlunparse(
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function normalizeLinkText refactored with the following changes:

if c >= 0xFDD0 and c <= 0xFDEF:
return False
if ((c & 0xFFFF) == 0xFFFF) or ((c & 0xFFFF) == 0xFFFE):
if c & 0xFFFF in [0xFFFF, 0xFFFE]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function isValidEntityCode refactored with the following changes:


ESCAPABLE = r"""\\!"#$%&'()*+,./:;<=>?@\[\]^`{}|_~-"""
ESCAPE_CHAR = re.compile(r"\\([" + ESCAPABLE + r"])")
ESCAPE_CHAR = re.compile(f'\\\\([{ESCAPABLE}])')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 153-153 refactored with the following changes:

def escapeRE(string: str) -> str:
string = REGEXP_ESCAPE_RE.sub("\\$&", string)
return string
return REGEXP_ESCAPE_RE.sub("\\$&", string)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function escapeRE refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant