janito 2.3.0__py3-none-any.whl → 2.3.1__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.
- janito/__init__.py +6 -6
- janito/cli/chat_mode/shell/autocomplete.py +21 -21
- janito/cli/chat_mode/shell/commands/clear.py +12 -12
- janito/cli/chat_mode/shell/commands/multi.py +51 -51
- janito/cli/chat_mode/shell/input_history.py +62 -62
- janito/cli/cli_commands/list_models.py +35 -35
- janito/cli/cli_commands/list_providers.py +9 -9
- janito/cli/cli_commands/list_tools.py +53 -53
- janito/cli/cli_commands/model_selection.py +50 -50
- janito/cli/cli_commands/model_utils.py +95 -95
- janito/cli/cli_commands/set_api_key.py +19 -19
- janito/cli/cli_commands/show_config.py +51 -51
- janito/cli/cli_commands/show_system_prompt.py +62 -62
- janito/cli/core/__init__.py +4 -4
- janito/cli/core/event_logger.py +59 -59
- janito/cli/core/getters.py +33 -33
- janito/cli/core/unsetters.py +54 -54
- janito/cli/single_shot_mode/__init__.py +6 -6
- janito/config.py +5 -5
- janito/config_manager.py +112 -112
- janito/drivers/anthropic/driver.py +113 -113
- janito/formatting_token.py +54 -54
- janito/i18n/__init__.py +35 -35
- janito/i18n/messages.py +23 -23
- janito/i18n/pt.py +47 -47
- janito/llm/__init__.py +5 -5
- janito/llm/agent.py +443 -443
- janito/llm/auth.py +63 -63
- janito/llm/driver_config_builder.py +34 -34
- janito/llm/driver_input.py +12 -12
- janito/llm/message_parts.py +60 -60
- janito/llm/model.py +38 -38
- janito/llm/provider.py +196 -196
- janito/provider_registry.py +176 -176
- janito/providers/anthropic/model_info.py +22 -22
- janito/providers/anthropic/provider.py +2 -0
- janito/providers/azure_openai/model_info.py +16 -16
- janito/providers/azure_openai/provider.py +3 -0
- janito/providers/deepseek/__init__.py +1 -1
- janito/providers/deepseek/model_info.py +16 -16
- janito/providers/deepseek/provider.py +94 -91
- janito/providers/google/provider.py +3 -0
- janito/providers/mistralai/provider.py +3 -0
- janito/providers/openai/provider.py +4 -0
- janito/tools/adapters/__init__.py +1 -1
- janito/tools/adapters/local/ask_user.py +102 -102
- janito/tools/adapters/local/copy_file.py +84 -84
- janito/tools/adapters/local/create_directory.py +69 -69
- janito/tools/adapters/local/create_file.py +82 -82
- janito/tools/adapters/local/fetch_url.py +97 -97
- janito/tools/adapters/local/find_files.py +138 -138
- janito/tools/adapters/local/get_file_outline/__init__.py +1 -1
- janito/tools/adapters/local/get_file_outline/core.py +117 -117
- janito/tools/adapters/local/get_file_outline/java_outline.py +40 -40
- janito/tools/adapters/local/get_file_outline/markdown_outline.py +14 -14
- janito/tools/adapters/local/get_file_outline/python_outline.py +303 -303
- janito/tools/adapters/local/get_file_outline/python_outline_v2.py +156 -156
- janito/tools/adapters/local/get_file_outline/search_outline.py +33 -33
- janito/tools/adapters/local/python_code_run.py +166 -166
- janito/tools/adapters/local/python_command_run.py +164 -164
- janito/tools/adapters/local/python_file_run.py +163 -163
- janito/tools/adapters/local/run_bash_command.py +176 -176
- janito/tools/adapters/local/run_powershell_command.py +219 -219
- janito/tools/adapters/local/search_text/__init__.py +1 -1
- janito/tools/adapters/local/search_text/core.py +201 -201
- janito/tools/adapters/local/search_text/pattern_utils.py +73 -73
- janito/tools/adapters/local/search_text/traverse_directory.py +145 -145
- janito/tools/adapters/local/validate_file_syntax/__init__.py +1 -1
- janito/tools/adapters/local/validate_file_syntax/core.py +106 -106
- janito/tools/adapters/local/validate_file_syntax/css_validator.py +35 -35
- janito/tools/adapters/local/validate_file_syntax/html_validator.py +93 -93
- janito/tools/adapters/local/validate_file_syntax/js_validator.py +27 -27
- janito/tools/adapters/local/validate_file_syntax/json_validator.py +6 -6
- janito/tools/adapters/local/validate_file_syntax/markdown_validator.py +109 -109
- janito/tools/adapters/local/validate_file_syntax/ps1_validator.py +32 -32
- janito/tools/adapters/local/validate_file_syntax/python_validator.py +5 -5
- janito/tools/adapters/local/validate_file_syntax/xml_validator.py +11 -11
- janito/tools/adapters/local/validate_file_syntax/yaml_validator.py +6 -6
- janito/tools/adapters/local/view_file.py +167 -167
- janito/tools/inspect_registry.py +17 -17
- janito/tools/tool_base.py +105 -105
- janito/tools/tool_events.py +58 -58
- janito/tools/tool_run_exception.py +12 -12
- janito/tools/tool_use_tracker.py +81 -81
- janito/tools/tool_utils.py +45 -45
- janito/tools/tools_schema.py +104 -104
- janito/version.py +4 -4
- {janito-2.3.0.dist-info → janito-2.3.1.dist-info}/METADATA +390 -388
- {janito-2.3.0.dist-info → janito-2.3.1.dist-info}/RECORD +93 -93
- {janito-2.3.0.dist-info → janito-2.3.1.dist-info}/WHEEL +0 -0
- {janito-2.3.0.dist-info → janito-2.3.1.dist-info}/entry_points.txt +0 -0
- {janito-2.3.0.dist-info → janito-2.3.1.dist-info}/licenses/LICENSE +0 -0
- {janito-2.3.0.dist-info → janito-2.3.1.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"
|