Fix #107265: Compositor: output node remove note that z-depth can be saved #104457
@ -49,20 +49,51 @@ def check_word(w):
|
|||||||
return dict_spelling.check(w)
|
return dict_spelling.check(w)
|
||||||
|
|
||||||
|
|
||||||
# Match HTML link `Text <url>`__
|
def regex_key_raise(x):
|
||||||
# A URL may span multiple lines.
|
raise Exception("Unknown role! " + "".join(x.groups()))
|
||||||
RE_URL_LINKS = re.compile(r"(`)([^`<]+)(<[^`>]+>)(`)(__)", re.MULTILINE)
|
|
||||||
|
|
||||||
# Match `|substitution|` for removal.
|
|
||||||
RE_SUBST = re.compile(r"\|[a-zA-Z0-9_]+\|")
|
|
||||||
|
|
||||||
# :some_role:`Text <ref>`
|
# A table of regex and their replacement functions.
|
||||||
RE_ROLE_WITH_TEXT = re.compile(r"(:[A-Za-z_]+:)(`)([^`<]+)(<[^`>]+>)(`)", flags=re.MULTILINE)
|
#
|
||||||
|
# This is used to clean up text from `docutils.nodes.NodeVisitor.visit_Text` which doesn't remove inline markup.
|
||||||
|
# Note that in some cases the order matters, especially with include/excluding roles.
|
||||||
|
|
||||||
RE_ROLE_INCLUDE = re.compile(r"(:(menuselection|guilabel):)(`)([^`]+)(`)", flags=re.MULTILINE)
|
RE_TEXT_REPLACE_ROLES_INCLUDE = ("menuselection", "guilabel")
|
||||||
RE_ROLE_EXCLUDE = re.compile(r"(:(kbd|ref|doc|abbr):)(`)([^`]+)(`)", flags=re.MULTILINE)
|
RE_TEXT_REPLACE_ROLES_EXCLUDE = ("kbd", "ref", "doc", "abbr")
|
||||||
|
|
||||||
RE_ROLE_ANY = re.compile(r"(:[A-Za-z_]+:)(`)([^`]+)(`)", flags=re.MULTILINE)
|
RE_TEXT_REPLACE_TABLE = (
|
||||||
|
# Match HTML link: `Text <url>`__
|
||||||
|
# A URL may span multiple lines.
|
||||||
|
(
|
||||||
|
re.compile(r"(`)([^`<]+)(<[^`>]+>)(`)(__)", re.MULTILINE),
|
||||||
|
lambda x: x.groups()[1].strip(),
|
||||||
|
),
|
||||||
|
# Roles with plain-text: :some_role:`Text <ref>`
|
||||||
|
(
|
||||||
|
re.compile(r"(:[A-Za-z_]+:)(`)([^`<]+)(<[^`>]+>)(`)", flags=re.MULTILINE),
|
||||||
|
lambda x: x.groups()[2].strip(),
|
||||||
|
),
|
||||||
|
# Roles to always include.
|
||||||
|
(
|
||||||
|
re.compile(r"(:(" + ("|".join(RE_TEXT_REPLACE_ROLES_INCLUDE)) + r"):)(`)([^`]+)(`)", flags=re.MULTILINE),
|
||||||
|
lambda x: x.groups()[3].strip(),
|
||||||
|
),
|
||||||
|
# Roles to always exclude.
|
||||||
|
(
|
||||||
|
re.compile(r"(:(" + ("|".join(RE_TEXT_REPLACE_ROLES_EXCLUDE)) + r"):)(`)([^`]+)(`)", flags=re.MULTILINE),
|
||||||
|
lambda _: " ",
|
||||||
|
),
|
||||||
|
# Ensure all roles are handled.
|
||||||
|
(
|
||||||
|
re.compile(r"(:[A-Za-z_]+:)(`)([^`]+)(`)", flags=re.MULTILINE),
|
||||||
|
regex_key_raise,
|
||||||
|
),
|
||||||
|
# Match substitution for removal: `|identifier|`
|
||||||
|
(
|
||||||
|
re.compile(r"\|[a-zA-Z0-9_]+\|"),
|
||||||
|
lambda _: " ",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
RE_WORDS = re.compile(
|
RE_WORDS = re.compile(
|
||||||
r"\b("
|
r"\b("
|
||||||
@ -74,21 +105,11 @@ RE_WORDS = re.compile(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def regex_key_raise(x):
|
|
||||||
raise Exception("Unknown role! " + "".join(x.groups()))
|
|
||||||
|
|
||||||
|
|
||||||
def check_spelling_body(text):
|
def check_spelling_body(text):
|
||||||
|
|
||||||
text = re.sub(RE_URL_LINKS, lambda x: x.groups()[1].strip(), text)
|
# Wash text or inline RST.
|
||||||
text = re.sub(RE_ROLE_WITH_TEXT, lambda x: x.groups()[2].strip(), text)
|
for re_expr, re_replace_fn in RE_TEXT_REPLACE_TABLE:
|
||||||
text = re.sub(RE_ROLE_INCLUDE, lambda x: x.groups()[3].strip(), text)
|
text = re.sub(re_expr, re_replace_fn, text)
|
||||||
|
|
||||||
text = re.sub(RE_ROLE_EXCLUDE, lambda _: " ", text)
|
|
||||||
text = re.sub(RE_ROLE_ANY, regex_key_raise, text)
|
|
||||||
|
|
||||||
# Remove substitutions.
|
|
||||||
text = re.sub(RE_SUBST, lambda _: " ", text)
|
|
||||||
|
|
||||||
for re_match in RE_WORDS.finditer(text):
|
for re_match in RE_WORDS.finditer(text):
|
||||||
w = re_match.group(0)
|
w = re_match.group(0)
|
||||||
|
Loading…
Reference in New Issue
Block a user