MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / suspicious_code_formatted_math

Function suspicious_code_formatted_math

scripts/lint_note.py:982–1026  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

980
981
982def suspicious_code_formatted_math(text: str) -> list[dict[str, object]]:
983 issues: list[dict[str, object]] = []
984 lines = text.splitlines()
985 in_fence = False
986 fence_start = 0
987 fence_lines: list[str] = []
988
989 for idx, line in enumerate(lines, start=1):
990 stripped = line.strip()
991 if stripped.startswith("```"):
992 if not in_fence:
993 in_fence = True
994 fence_start = idx
995 fence_lines = []
996 else:
997 fence_text = "\n".join(fence_lines)
998 if re.search(r"(?:^|\\n)\s*(?:[A-Za-z][A-Za-z0-9_]*\s*=|O\(|\\sum|\\prod|\\mathcal|\\log|\\frac)", fence_text):
999 issues.append(
1000 {
1001 "line_number": fence_start,
1002 "line": "```",
1003 "next_line": fence_lines[0].strip() if fence_lines else "",
1004 "kind": "fenced_math_like_block",
1005 }
1006 )
1007 in_fence = False
1008 fence_start = 0
1009 fence_lines = []
1010 continue
1011 if in_fence:
1012 fence_lines.append(line)
1013 continue
1014 for match in re.finditer(r"`([^`\n]{3,120})`", line):
1015 content = match.group(1).strip()
1016 if re.search(r"(=|O\(|\\sum|\\prod|\\mathcal|\\log|\\frac)", content):
1017 issues.append(
1018 {
1019 "line_number": idx,
1020 "line": line.strip(),
1021 "next_line": content,
1022 "kind": "inline_code_math_like",
1023 }
1024 )
1025 break
1026 return issues
1027
1028
1029def _line_number_from_offset(text: str, offset: int) -> int:

Calls

no outgoing calls