janito 2.2.0__py3-none-any.whl → 2.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. janito/__init__.py +6 -6
  2. janito/agent/setup_agent.py +14 -5
  3. janito/agent/templates/profiles/system_prompt_template_main.txt.j2 +3 -1
  4. janito/cli/chat_mode/bindings.py +6 -0
  5. janito/cli/chat_mode/session.py +16 -0
  6. janito/cli/chat_mode/shell/autocomplete.py +21 -21
  7. janito/cli/chat_mode/shell/commands/__init__.py +3 -0
  8. janito/cli/chat_mode/shell/commands/clear.py +12 -12
  9. janito/cli/chat_mode/shell/commands/exec.py +27 -0
  10. janito/cli/chat_mode/shell/commands/multi.py +51 -51
  11. janito/cli/chat_mode/shell/commands/tools.py +17 -6
  12. janito/cli/chat_mode/shell/input_history.py +62 -62
  13. janito/cli/chat_mode/shell/session/manager.py +1 -0
  14. janito/cli/chat_mode/toolbar.py +1 -0
  15. janito/cli/cli_commands/list_models.py +35 -35
  16. janito/cli/cli_commands/list_providers.py +9 -9
  17. janito/cli/cli_commands/list_tools.py +53 -53
  18. janito/cli/cli_commands/model_selection.py +50 -50
  19. janito/cli/cli_commands/model_utils.py +13 -2
  20. janito/cli/cli_commands/set_api_key.py +19 -19
  21. janito/cli/cli_commands/show_config.py +51 -51
  22. janito/cli/cli_commands/show_system_prompt.py +62 -62
  23. janito/cli/config.py +2 -1
  24. janito/cli/core/__init__.py +4 -4
  25. janito/cli/core/event_logger.py +59 -59
  26. janito/cli/core/getters.py +3 -1
  27. janito/cli/core/runner.py +165 -148
  28. janito/cli/core/setters.py +5 -1
  29. janito/cli/core/unsetters.py +54 -54
  30. janito/cli/main_cli.py +12 -1
  31. janito/cli/prompt_core.py +5 -2
  32. janito/cli/rich_terminal_reporter.py +22 -3
  33. janito/cli/single_shot_mode/__init__.py +6 -6
  34. janito/cli/single_shot_mode/handler.py +11 -1
  35. janito/cli/verbose_output.py +1 -1
  36. janito/config.py +5 -5
  37. janito/config_manager.py +2 -0
  38. janito/driver_events.py +14 -0
  39. janito/drivers/anthropic/driver.py +113 -113
  40. janito/drivers/azure_openai/driver.py +38 -3
  41. janito/drivers/driver_registry.py +0 -2
  42. janito/drivers/openai/driver.py +196 -36
  43. janito/formatting_token.py +54 -54
  44. janito/i18n/__init__.py +35 -35
  45. janito/i18n/messages.py +23 -23
  46. janito/i18n/pt.py +47 -47
  47. janito/llm/__init__.py +5 -5
  48. janito/llm/agent.py +443 -443
  49. janito/llm/auth.py +1 -0
  50. janito/llm/driver.py +7 -1
  51. janito/llm/driver_config.py +1 -0
  52. janito/llm/driver_config_builder.py +34 -34
  53. janito/llm/driver_input.py +12 -12
  54. janito/llm/message_parts.py +60 -60
  55. janito/llm/model.py +38 -38
  56. janito/llm/provider.py +196 -196
  57. janito/provider_config.py +7 -3
  58. janito/provider_registry.py +176 -158
  59. janito/providers/__init__.py +1 -0
  60. janito/providers/anthropic/model_info.py +22 -22
  61. janito/providers/anthropic/provider.py +2 -2
  62. janito/providers/azure_openai/model_info.py +7 -6
  63. janito/providers/azure_openai/provider.py +30 -2
  64. janito/providers/deepseek/__init__.py +1 -1
  65. janito/providers/deepseek/model_info.py +16 -16
  66. janito/providers/deepseek/provider.py +91 -91
  67. janito/providers/google/model_info.py +21 -29
  68. janito/providers/google/provider.py +49 -38
  69. janito/providers/mistralai/provider.py +2 -2
  70. janito/providers/provider_static_info.py +2 -3
  71. janito/tools/adapters/__init__.py +1 -1
  72. janito/tools/adapters/local/adapter.py +33 -11
  73. janito/tools/adapters/local/ask_user.py +102 -102
  74. janito/tools/adapters/local/copy_file.py +84 -84
  75. janito/tools/adapters/local/create_directory.py +69 -69
  76. janito/tools/adapters/local/create_file.py +82 -82
  77. janito/tools/adapters/local/delete_text_in_file.py +4 -7
  78. janito/tools/adapters/local/fetch_url.py +97 -97
  79. janito/tools/adapters/local/find_files.py +138 -138
  80. janito/tools/adapters/local/get_file_outline/__init__.py +1 -1
  81. janito/tools/adapters/local/get_file_outline/core.py +117 -117
  82. janito/tools/adapters/local/get_file_outline/java_outline.py +40 -40
  83. janito/tools/adapters/local/get_file_outline/markdown_outline.py +14 -14
  84. janito/tools/adapters/local/get_file_outline/python_outline.py +303 -303
  85. janito/tools/adapters/local/get_file_outline/python_outline_v2.py +156 -156
  86. janito/tools/adapters/local/get_file_outline/search_outline.py +33 -33
  87. janito/tools/adapters/local/move_file.py +3 -13
  88. janito/tools/adapters/local/python_code_run.py +166 -166
  89. janito/tools/adapters/local/python_command_run.py +164 -164
  90. janito/tools/adapters/local/python_file_run.py +163 -163
  91. janito/tools/adapters/local/remove_directory.py +6 -17
  92. janito/tools/adapters/local/remove_file.py +4 -10
  93. janito/tools/adapters/local/replace_text_in_file.py +6 -9
  94. janito/tools/adapters/local/run_bash_command.py +176 -176
  95. janito/tools/adapters/local/run_powershell_command.py +219 -219
  96. janito/tools/adapters/local/search_text/__init__.py +1 -1
  97. janito/tools/adapters/local/search_text/core.py +201 -201
  98. janito/tools/adapters/local/search_text/match_lines.py +1 -1
  99. janito/tools/adapters/local/search_text/pattern_utils.py +73 -73
  100. janito/tools/adapters/local/search_text/traverse_directory.py +145 -145
  101. janito/tools/adapters/local/validate_file_syntax/__init__.py +1 -1
  102. janito/tools/adapters/local/validate_file_syntax/core.py +106 -106
  103. janito/tools/adapters/local/validate_file_syntax/css_validator.py +35 -35
  104. janito/tools/adapters/local/validate_file_syntax/html_validator.py +93 -93
  105. janito/tools/adapters/local/validate_file_syntax/js_validator.py +27 -27
  106. janito/tools/adapters/local/validate_file_syntax/json_validator.py +6 -6
  107. janito/tools/adapters/local/validate_file_syntax/markdown_validator.py +109 -109
  108. janito/tools/adapters/local/validate_file_syntax/ps1_validator.py +32 -32
  109. janito/tools/adapters/local/validate_file_syntax/python_validator.py +5 -5
  110. janito/tools/adapters/local/validate_file_syntax/xml_validator.py +11 -11
  111. janito/tools/adapters/local/validate_file_syntax/yaml_validator.py +6 -6
  112. janito/tools/adapters/local/view_file.py +167 -167
  113. janito/tools/inspect_registry.py +17 -17
  114. janito/tools/tool_base.py +105 -105
  115. janito/tools/tool_events.py +58 -58
  116. janito/tools/tool_run_exception.py +12 -12
  117. janito/tools/tool_use_tracker.py +81 -81
  118. janito/tools/tool_utils.py +45 -45
  119. janito/tools/tools_adapter.py +78 -6
  120. janito/tools/tools_schema.py +104 -104
  121. janito/version.py +4 -4
  122. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/METADATA +388 -251
  123. janito-2.3.0.dist-info/RECORD +181 -0
  124. janito/drivers/google_genai/driver.py +0 -54
  125. janito/drivers/google_genai/schema_generator.py +0 -67
  126. janito-2.2.0.dist-info/RECORD +0 -182
  127. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/WHEEL +0 -0
  128. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/entry_points.txt +0 -0
  129. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/licenses/LICENSE +0 -0
  130. {janito-2.2.0.dist-info → janito-2.3.0.dist-info}/top_level.txt +0 -0
@@ -1,93 +1,93 @@
1
- from janito.i18n import tr
2
- import re
3
- from lxml import etree
4
-
5
-
6
- def validate_html(file_path: str) -> str:
7
- html_content = _read_html_content(file_path)
8
- warnings = _find_js_outside_script(html_content)
9
- lxml_error = _parse_html_and_collect_errors(file_path)
10
- msg = _build_result_message(warnings, lxml_error)
11
- return msg
12
-
13
-
14
- def _read_html_content(file_path):
15
- with open(file_path, "r", encoding="utf-8") as f:
16
- return f.read()
17
-
18
-
19
- def _find_js_outside_script(html_content):
20
- script_blocks = [
21
- m.span()
22
- for m in re.finditer(
23
- r"<script[\s\S]*?>[\s\S]*?<\/script>", html_content, re.IGNORECASE
24
- )
25
- ]
26
- js_patterns = [
27
- r"document\.addEventListener",
28
- r"^\s*(var|let|const)\s+\w+\s*[=;]",
29
- r"^\s*function\s+\w+\s*\(",
30
- r"^\s*(const|let|var)\s+\w+\s*=\s*\(.*\)\s*=>",
31
- r"^\s*window\.\w+\s*=",
32
- r"^\s*\$\s*\(",
33
- ]
34
- warnings = []
35
- for pat in js_patterns:
36
- for m in re.finditer(pat, html_content):
37
- in_script = False
38
- for s_start, s_end in script_blocks:
39
- if s_start <= m.start() < s_end:
40
- in_script = True
41
- break
42
- if not in_script:
43
- warnings.append(
44
- f"Line {html_content.count(chr(10), 0, m.start())+1}: JavaScript code ('{pat}') found outside <script> tag."
45
- )
46
- return warnings
47
-
48
-
49
- def _parse_html_and_collect_errors(file_path):
50
- lxml_error = None
51
- try:
52
- parser = etree.HTMLParser(recover=False)
53
- with open(file_path, "rb") as f:
54
- etree.parse(f, parser=parser)
55
- error_log = parser.error_log
56
- syntax_errors = []
57
- for e in error_log:
58
- if (
59
- "mismatch" in e.message.lower()
60
- or "tag not closed" in e.message.lower()
61
- or "unexpected end tag" in e.message.lower()
62
- or "expected" in e.message.lower()
63
- ):
64
- syntax_errors.append(str(e))
65
- if syntax_errors:
66
- lxml_error = tr("Syntax error: {error}", error="; ".join(syntax_errors))
67
- elif error_log:
68
- lxml_error = tr(
69
- "HTML syntax errors found:\n{errors}",
70
- errors="\n".join(str(e) for e in error_log),
71
- )
72
- except ImportError:
73
- lxml_error = tr("⚠️ lxml not installed. Cannot validate HTML.")
74
- except Exception as e:
75
- lxml_error = tr("Syntax error: {error}", error=str(e))
76
- return lxml_error
77
-
78
-
79
- def _build_result_message(warnings, lxml_error):
80
- msg = ""
81
- if warnings:
82
- msg += (
83
- tr(
84
- "⚠️ Warning: JavaScript code found outside <script> tags. This is invalid HTML and will not execute in browsers.\n"
85
- + "\n".join(warnings)
86
- )
87
- + "\n"
88
- )
89
- if lxml_error:
90
- msg += lxml_error
91
- if msg:
92
- return msg.strip()
93
- return "✅ OK"
1
+ from janito.i18n import tr
2
+ import re
3
+ from lxml import etree
4
+
5
+
6
+ def validate_html(file_path: str) -> str:
7
+ html_content = _read_html_content(file_path)
8
+ warnings = _find_js_outside_script(html_content)
9
+ lxml_error = _parse_html_and_collect_errors(file_path)
10
+ msg = _build_result_message(warnings, lxml_error)
11
+ return msg
12
+
13
+
14
+ def _read_html_content(file_path):
15
+ with open(file_path, "r", encoding="utf-8") as f:
16
+ return f.read()
17
+
18
+
19
+ def _find_js_outside_script(html_content):
20
+ script_blocks = [
21
+ m.span()
22
+ for m in re.finditer(
23
+ r"<script[\s\S]*?>[\s\S]*?<\/script>", html_content, re.IGNORECASE
24
+ )
25
+ ]
26
+ js_patterns = [
27
+ r"document\.addEventListener",
28
+ r"^\s*(var|let|const)\s+\w+\s*[=;]",
29
+ r"^\s*function\s+\w+\s*\(",
30
+ r"^\s*(const|let|var)\s+\w+\s*=\s*\(.*\)\s*=>",
31
+ r"^\s*window\.\w+\s*=",
32
+ r"^\s*\$\s*\(",
33
+ ]
34
+ warnings = []
35
+ for pat in js_patterns:
36
+ for m in re.finditer(pat, html_content):
37
+ in_script = False
38
+ for s_start, s_end in script_blocks:
39
+ if s_start <= m.start() < s_end:
40
+ in_script = True
41
+ break
42
+ if not in_script:
43
+ warnings.append(
44
+ f"Line {html_content.count(chr(10), 0, m.start())+1}: JavaScript code ('{pat}') found outside <script> tag."
45
+ )
46
+ return warnings
47
+
48
+
49
+ def _parse_html_and_collect_errors(file_path):
50
+ lxml_error = None
51
+ try:
52
+ parser = etree.HTMLParser(recover=False)
53
+ with open(file_path, "rb") as f:
54
+ etree.parse(f, parser=parser)
55
+ error_log = parser.error_log
56
+ syntax_errors = []
57
+ for e in error_log:
58
+ if (
59
+ "mismatch" in e.message.lower()
60
+ or "tag not closed" in e.message.lower()
61
+ or "unexpected end tag" in e.message.lower()
62
+ or "expected" in e.message.lower()
63
+ ):
64
+ syntax_errors.append(str(e))
65
+ if syntax_errors:
66
+ lxml_error = tr("Syntax error: {error}", error="; ".join(syntax_errors))
67
+ elif error_log:
68
+ lxml_error = tr(
69
+ "HTML syntax errors found:\n{errors}",
70
+ errors="\n".join(str(e) for e in error_log),
71
+ )
72
+ except ImportError:
73
+ lxml_error = tr("⚠️ lxml not installed. Cannot validate HTML.")
74
+ except Exception as e:
75
+ lxml_error = tr("Syntax error: {error}", error=str(e))
76
+ return lxml_error
77
+
78
+
79
+ def _build_result_message(warnings, lxml_error):
80
+ msg = ""
81
+ if warnings:
82
+ msg += (
83
+ tr(
84
+ "⚠️ Warning: JavaScript code found outside <script> tags. This is invalid HTML and will not execute in browsers.\n"
85
+ + "\n".join(warnings)
86
+ )
87
+ + "\n"
88
+ )
89
+ if lxml_error:
90
+ msg += lxml_error
91
+ if msg:
92
+ return msg.strip()
93
+ return "✅ OK"
@@ -1,27 +1,27 @@
1
- from janito.i18n import tr
2
- import re
3
-
4
-
5
- def validate_js(file_path: str) -> str:
6
- with open(file_path, "r", encoding="utf-8") as f:
7
- content = f.read()
8
- errors = []
9
- if content.count("{") != content.count("}"):
10
- errors.append("Unmatched curly braces { }")
11
- if content.count("(") != content.count(")"):
12
- errors.append("Unmatched parentheses ( )")
13
- if content.count("[") != content.count("]"):
14
- errors.append("Unmatched brackets [ ]")
15
- for quote in ["'", '"', "`"]:
16
- unescaped = re.findall(rf"(?<!\\){quote}", content)
17
- if len(unescaped) % 2 != 0:
18
- errors.append(f"Unclosed string literal ({quote}) detected")
19
- if content.count("/*") != content.count("*/"):
20
- errors.append("Unclosed block comment (/* ... */)")
21
- if errors:
22
- msg = tr(
23
- "⚠️ Warning: JavaScript syntax issues found:\n{errors}",
24
- errors="\n".join(errors),
25
- )
26
- return msg
27
- return "✅ OK"
1
+ from janito.i18n import tr
2
+ import re
3
+
4
+
5
+ def validate_js(file_path: str) -> str:
6
+ with open(file_path, "r", encoding="utf-8") as f:
7
+ content = f.read()
8
+ errors = []
9
+ if content.count("{") != content.count("}"):
10
+ errors.append("Unmatched curly braces { }")
11
+ if content.count("(") != content.count(")"):
12
+ errors.append("Unmatched parentheses ( )")
13
+ if content.count("[") != content.count("]"):
14
+ errors.append("Unmatched brackets [ ]")
15
+ for quote in ["'", '"', "`"]:
16
+ unescaped = re.findall(rf"(?<!\\){quote}", content)
17
+ if len(unescaped) % 2 != 0:
18
+ errors.append(f"Unclosed string literal ({quote}) detected")
19
+ if content.count("/*") != content.count("*/"):
20
+ errors.append("Unclosed block comment (/* ... */)")
21
+ if errors:
22
+ msg = tr(
23
+ "⚠️ Warning: JavaScript syntax issues found:\n{errors}",
24
+ errors="\n".join(errors),
25
+ )
26
+ return msg
27
+ return "✅ OK"
@@ -1,6 +1,6 @@
1
- def validate_json(file_path: str) -> str:
2
- import json
3
-
4
- with open(file_path, "r", encoding="utf-8") as f:
5
- json.load(f)
6
- return "✅ OK"
1
+ def validate_json(file_path: str) -> str:
2
+ import json
3
+
4
+ with open(file_path, "r", encoding="utf-8") as f:
5
+ json.load(f)
6
+ return "✅ OK"
@@ -1,109 +1,109 @@
1
- from janito.i18n import tr
2
- import re
3
-
4
-
5
- def validate_markdown(file_path: str) -> str:
6
- with open(file_path, "r", encoding="utf-8") as f:
7
- content = f.read()
8
- lines = content.splitlines()
9
- errors = []
10
- errors.extend(_check_header_space(lines))
11
- errors.extend(_check_unclosed_code_block(content))
12
- errors.extend(_check_unclosed_links_images(lines))
13
- errors.extend(_check_list_formatting(lines))
14
- errors.extend(_check_unclosed_inline_code(content))
15
- return _build_markdown_result(errors)
16
-
17
-
18
- def _check_header_space(lines):
19
- errors = []
20
- for i, line in enumerate(lines, 1):
21
- if re.match(r"^#+[^ #]", line):
22
- errors.append(f"Line {i}: Header missing space after # | {line.strip()}")
23
- return errors
24
-
25
-
26
- def _check_unclosed_code_block(content):
27
- errors = []
28
- if content.count("```") % 2 != 0:
29
- errors.append("Unclosed code block (```) detected")
30
- return errors
31
-
32
-
33
- def _check_unclosed_links_images(lines):
34
- errors = []
35
- for i, line in enumerate(lines, 1):
36
- if re.search(r"\[[^\]]*\]\([^)]+$", line):
37
- errors.append(
38
- f"Line {i}: Unclosed link or image (missing closing parenthesis) | {line.strip()}"
39
- )
40
- return errors
41
-
42
-
43
- def _is_table_line(line):
44
- return line.lstrip().startswith("|")
45
-
46
-
47
- def _list_item_missing_space(line):
48
- return re.match(r"^[-*+][^ \n]", line)
49
-
50
-
51
- def _should_skip_list_item(line):
52
- stripped = line.strip()
53
- return stripped.startswith("*") and stripped.endswith("*") and len(stripped) > 2
54
-
55
-
56
- def _needs_blank_line_before_bullet(lines, i):
57
- if i <= 1:
58
- return False
59
- prev_line = lines[i - 2]
60
- prev_is_list = bool(re.match(r"^\s*[-*+] ", prev_line))
61
- return not prev_is_list and prev_line.strip() != ""
62
-
63
-
64
- def _needs_blank_line_before_numbered(lines, i):
65
- if i <= 1:
66
- return False
67
- prev_line = lines[i - 2]
68
- prev_is_numbered_list = bool(re.match(r"^\s*\d+\. ", prev_line))
69
- return not prev_is_numbered_list and prev_line.strip() != ""
70
-
71
-
72
- def _check_list_formatting(lines):
73
- errors = []
74
- for i, line in enumerate(lines, 1):
75
- if _is_table_line(line):
76
- continue
77
- if _list_item_missing_space(line):
78
- if not _should_skip_list_item(line):
79
- errors.append(
80
- f"Line {i}: List item missing space after bullet | {line.strip()}"
81
- )
82
- if re.match(r"^\s*[-*+] ", line):
83
- if _needs_blank_line_before_bullet(lines, i):
84
- errors.append(
85
- f"Line {i}: List should be preceded by a blank line for compatibility with MkDocs and other Markdown parsers | {line.strip()}"
86
- )
87
- if re.match(r"^\s*\d+\. ", line):
88
- if _needs_blank_line_before_numbered(lines, i):
89
- errors.append(
90
- f"Line {i}: Numbered list should be preceded by a blank line for compatibility with MkDocs and other Markdown parsers | {line.strip()}"
91
- )
92
- return errors
93
-
94
-
95
- def _check_unclosed_inline_code(content):
96
- errors = []
97
- if content.count("`") % 2 != 0:
98
- errors.append("Unclosed inline code (`) detected")
99
- return errors
100
-
101
-
102
- def _build_markdown_result(errors):
103
- if errors:
104
- msg = tr(
105
- "⚠️ Warning: Markdown syntax issues found:\n{errors}",
106
- errors="\n".join(errors),
107
- )
108
- return msg
109
- return "✅ OK"
1
+ from janito.i18n import tr
2
+ import re
3
+
4
+
5
+ def validate_markdown(file_path: str) -> str:
6
+ with open(file_path, "r", encoding="utf-8") as f:
7
+ content = f.read()
8
+ lines = content.splitlines()
9
+ errors = []
10
+ errors.extend(_check_header_space(lines))
11
+ errors.extend(_check_unclosed_code_block(content))
12
+ errors.extend(_check_unclosed_links_images(lines))
13
+ errors.extend(_check_list_formatting(lines))
14
+ errors.extend(_check_unclosed_inline_code(content))
15
+ return _build_markdown_result(errors)
16
+
17
+
18
+ def _check_header_space(lines):
19
+ errors = []
20
+ for i, line in enumerate(lines, 1):
21
+ if re.match(r"^#+[^ #]", line):
22
+ errors.append(f"Line {i}: Header missing space after # | {line.strip()}")
23
+ return errors
24
+
25
+
26
+ def _check_unclosed_code_block(content):
27
+ errors = []
28
+ if content.count("```") % 2 != 0:
29
+ errors.append("Unclosed code block (```) detected")
30
+ return errors
31
+
32
+
33
+ def _check_unclosed_links_images(lines):
34
+ errors = []
35
+ for i, line in enumerate(lines, 1):
36
+ if re.search(r"\[[^\]]*\]\([^)]+$", line):
37
+ errors.append(
38
+ f"Line {i}: Unclosed link or image (missing closing parenthesis) | {line.strip()}"
39
+ )
40
+ return errors
41
+
42
+
43
+ def _is_table_line(line):
44
+ return line.lstrip().startswith("|")
45
+
46
+
47
+ def _list_item_missing_space(line):
48
+ return re.match(r"^[-*+][^ \n]", line)
49
+
50
+
51
+ def _should_skip_list_item(line):
52
+ stripped = line.strip()
53
+ return stripped.startswith("*") and stripped.endswith("*") and len(stripped) > 2
54
+
55
+
56
+ def _needs_blank_line_before_bullet(lines, i):
57
+ if i <= 1:
58
+ return False
59
+ prev_line = lines[i - 2]
60
+ prev_is_list = bool(re.match(r"^\s*[-*+] ", prev_line))
61
+ return not prev_is_list and prev_line.strip() != ""
62
+
63
+
64
+ def _needs_blank_line_before_numbered(lines, i):
65
+ if i <= 1:
66
+ return False
67
+ prev_line = lines[i - 2]
68
+ prev_is_numbered_list = bool(re.match(r"^\s*\d+\. ", prev_line))
69
+ return not prev_is_numbered_list and prev_line.strip() != ""
70
+
71
+
72
+ def _check_list_formatting(lines):
73
+ errors = []
74
+ for i, line in enumerate(lines, 1):
75
+ if _is_table_line(line):
76
+ continue
77
+ if _list_item_missing_space(line):
78
+ if not _should_skip_list_item(line):
79
+ errors.append(
80
+ f"Line {i}: List item missing space after bullet | {line.strip()}"
81
+ )
82
+ if re.match(r"^\s*[-*+] ", line):
83
+ if _needs_blank_line_before_bullet(lines, i):
84
+ errors.append(
85
+ f"Line {i}: List should be preceded by a blank line for compatibility with MkDocs and other Markdown parsers | {line.strip()}"
86
+ )
87
+ if re.match(r"^\s*\d+\. ", line):
88
+ if _needs_blank_line_before_numbered(lines, i):
89
+ errors.append(
90
+ f"Line {i}: Numbered list should be preceded by a blank line for compatibility with MkDocs and other Markdown parsers | {line.strip()}"
91
+ )
92
+ return errors
93
+
94
+
95
+ def _check_unclosed_inline_code(content):
96
+ errors = []
97
+ if content.count("`") % 2 != 0:
98
+ errors.append("Unclosed inline code (`) detected")
99
+ return errors
100
+
101
+
102
+ def _build_markdown_result(errors):
103
+ if errors:
104
+ msg = tr(
105
+ "⚠️ Warning: Markdown syntax issues found:\n{errors}",
106
+ errors="\n".join(errors),
107
+ )
108
+ return msg
109
+ return "✅ OK"
@@ -1,32 +1,32 @@
1
- from janito.i18n import tr
2
- import re
3
-
4
-
5
- def validate_ps1(file_path: str) -> str:
6
- with open(file_path, "r", encoding="utf-8") as f:
7
- content = f.read()
8
- errors = []
9
- # Unmatched curly braces
10
- if content.count("{") != content.count("}"):
11
- errors.append("Unmatched curly braces { }")
12
- # Unmatched parentheses
13
- if content.count("(") != content.count(")"):
14
- errors.append("Unmatched parentheses ( )")
15
- # Unmatched brackets
16
- if content.count("[") != content.count("]"):
17
- errors.append("Unmatched brackets [ ]")
18
- # Unclosed string literals
19
- for quote in ["'", '"']:
20
- unescaped = re.findall(rf"(?<!\\){quote}", content)
21
- if len(unescaped) % 2 != 0:
22
- errors.append(f"Unclosed string literal ({quote}) detected")
23
- # Unclosed block comments <# ... #>
24
- if content.count("<#") != content.count("#>"):
25
- errors.append("Unclosed block comment (<# ... #>)")
26
- if errors:
27
- msg = tr(
28
- "⚠️ Warning: PowerShell syntax issues found:\n{errors}",
29
- errors="\n".join(errors),
30
- )
31
- return msg
32
- return "✅ OK"
1
+ from janito.i18n import tr
2
+ import re
3
+
4
+
5
+ def validate_ps1(file_path: str) -> str:
6
+ with open(file_path, "r", encoding="utf-8") as f:
7
+ content = f.read()
8
+ errors = []
9
+ # Unmatched curly braces
10
+ if content.count("{") != content.count("}"):
11
+ errors.append("Unmatched curly braces { }")
12
+ # Unmatched parentheses
13
+ if content.count("(") != content.count(")"):
14
+ errors.append("Unmatched parentheses ( )")
15
+ # Unmatched brackets
16
+ if content.count("[") != content.count("]"):
17
+ errors.append("Unmatched brackets [ ]")
18
+ # Unclosed string literals
19
+ for quote in ["'", '"']:
20
+ unescaped = re.findall(rf"(?<!\\){quote}", content)
21
+ if len(unescaped) % 2 != 0:
22
+ errors.append(f"Unclosed string literal ({quote}) detected")
23
+ # Unclosed block comments <# ... #>
24
+ if content.count("<#") != content.count("#>"):
25
+ errors.append("Unclosed block comment (<# ... #>)")
26
+ if errors:
27
+ msg = tr(
28
+ "⚠️ Warning: PowerShell syntax issues found:\n{errors}",
29
+ errors="\n".join(errors),
30
+ )
31
+ return msg
32
+ return "✅ OK"
@@ -1,5 +1,5 @@
1
- def validate_python(file_path: str) -> str:
2
- import py_compile
3
-
4
- py_compile.compile(file_path, doraise=True)
5
- return "✅ OK"
1
+ def validate_python(file_path: str) -> str:
2
+ import py_compile
3
+
4
+ py_compile.compile(file_path, doraise=True)
5
+ return "✅ OK"
@@ -1,11 +1,11 @@
1
- from janito.i18n import tr
2
-
3
-
4
- def validate_xml(file_path: str) -> str:
5
- try:
6
- from lxml import etree
7
- except ImportError:
8
- return tr("⚠️ lxml not installed. Cannot validate XML.")
9
- with open(file_path, "rb") as f:
10
- etree.parse(f)
11
- return "✅ OK"
1
+ from janito.i18n import tr
2
+
3
+
4
+ def validate_xml(file_path: str) -> str:
5
+ try:
6
+ from lxml import etree
7
+ except ImportError:
8
+ return tr("⚠️ lxml not installed. Cannot validate XML.")
9
+ with open(file_path, "rb") as f:
10
+ etree.parse(f)
11
+ return "✅ OK"
@@ -1,6 +1,6 @@
1
- def validate_yaml(file_path: str) -> str:
2
- import yaml
3
-
4
- with open(file_path, "r", encoding="utf-8") as f:
5
- yaml.safe_load(f)
6
- return "✅ OK"
1
+ def validate_yaml(file_path: str) -> str:
2
+ import yaml
3
+
4
+ with open(file_path, "r", encoding="utf-8") as f:
5
+ yaml.safe_load(f)
6
+ return "✅ OK"