diff --git a/scripts/doc_parsing_utils.py b/scripts/doc_parsing_utils.py
index 5a75ec10f..1fa0592f1 100644
--- a/scripts/doc_parsing_utils.py
+++ b/scripts/doc_parsing_utils.py
@@ -441,7 +441,7 @@ def replace_html_links(
if len(links) != len(original_links):
raise ValueError(
- "Number of HTML links does not match the number of HTML links in the "
+ "Number of HTML links does not match the number in the "
"original document "
f"({len(links)} vs {len(original_links)})"
)
diff --git a/scripts/tests/test_translation_fixer/test_complex_doc/data/en_doc.md b/scripts/tests/test_translation_fixer/test_complex_doc/data/en_doc.md
index e223f22c1..3582b0491 100644
--- a/scripts/tests/test_translation_fixer/test_complex_doc/data/en_doc.md
+++ b/scripts/tests/test_translation_fixer/test_complex_doc/data/en_doc.md
@@ -188,6 +188,18 @@ This is an link to the main FastAPI site<
This is an link to one of the pages on FastAPI site - tool should add language code to the URL.
+Link to test wrong attribute: **FastAPI** Project Generators - tool should fix the attribute.
+
+### HTML links to static assets { #html-links-to-static-assets }
+
+These are links to static assets:
+
+* FastAPI Logo
+* FastAPI CSS
+* FastAPI JS
+
+Tool should NOT add language code to their URLs.
+
# Header (with HTML link to tiangolo.com) { #header-with-html-link-to-tiangolo-com }
#Not a header
diff --git a/scripts/tests/test_translation_fixer/test_complex_doc/data/translated_doc.md b/scripts/tests/test_translation_fixer/test_complex_doc/data/translated_doc.md
index 685261bf7..d92480ae8 100644
--- a/scripts/tests/test_translation_fixer/test_complex_doc/data/translated_doc.md
+++ b/scripts/tests/test_translation_fixer/test_complex_doc/data/translated_doc.md
@@ -183,6 +183,18 @@ def hello_world():// Печать приветствия
Это ссылка на одну из страниц на сайте FastAPI — инструмент должен добавить код языка в URL.
+Ссылка для тестирования неправильного атрибута: **FastAPI** генераторы проектов - инструмент должен исправить атрибут.
+
+### HTML ссылки на статические ресурсы { #html-links-to-static-assets }
+
+Это ссылки на статические ресурсы:
+
+* FastAPI Logo
+* FastAPI CSS
+* FastAPI JS
+
+Инструмент НЕ должен добавлять код языка в их URL.
+
# Заголовок (с HTML ссылкой на tiangolo.com) { #header-5 }
#Не заголовок
diff --git a/scripts/tests/test_translation_fixer/test_complex_doc/data/translated_doc_expected.md b/scripts/tests/test_translation_fixer/test_complex_doc/data/translated_doc_expected.md
index bc8664e70..b27e48632 100644
--- a/scripts/tests/test_translation_fixer/test_complex_doc/data/translated_doc_expected.md
+++ b/scripts/tests/test_translation_fixer/test_complex_doc/data/translated_doc_expected.md
@@ -183,6 +183,18 @@ def hello_world():// Print greeting
Это ссылка на одну из страниц на сайте FastAPI — инструмент должен добавить код языка в URL.
+Ссылка для тестирования неправильного атрибута: **FastAPI** генераторы проектов - инструмент должен исправить атрибут.
+
+### HTML ссылки на статические ресурсы { #html-links-to-static-assets }
+
+Это ссылки на статические ресурсы:
+
+* FastAPI Logo
+* FastAPI CSS
+* FastAPI JS
+
+Инструмент НЕ должен добавлять код языка в их URL.
+
# Заголовок (с HTML ссылкой на tiangolo.com) { #header-with-html-link-to-tiangolo-com }
#Не заголовок
diff --git a/scripts/tests/test_translation_fixer/test_html_links/data/en_doc.md b/scripts/tests/test_translation_fixer/test_html_links/data/en_doc.md
new file mode 100644
index 000000000..4c4d104cf
--- /dev/null
+++ b/scripts/tests/test_translation_fixer/test_html_links/data/en_doc.md
@@ -0,0 +1,19 @@
+# Header 1 { #header-1 }
+
+Some text with a link to FastAPI.
+
+## Header 2 { #header-2 }
+
+Two links here: How to and Project Generators.
+
+### Header 3 { #header-3 }
+
+Another link: **FastAPI** Project Generators with title.
+
+# Header 4 { #header-4 }
+
+Link to anchor: Header 2
+
+# Header with link { #header-with-link }
+
+Some text
diff --git a/scripts/tests/test_translation_fixer/test_html_links/data/translated_doc_number_gt.md b/scripts/tests/test_translation_fixer/test_html_links/data/translated_doc_number_gt.md
new file mode 100644
index 000000000..bac40242b
--- /dev/null
+++ b/scripts/tests/test_translation_fixer/test_html_links/data/translated_doc_number_gt.md
@@ -0,0 +1,21 @@
+# Заголовок 1 { #header-1 }
+
+Немного текста со ссылкой на FastAPI.
+
+## Заголовок 2 { #header-2 }
+
+Две ссылки здесь: How to и Project Generators.
+
+### Заголовок 3 { #header-3 }
+
+Ещё ссылка: **FastAPI** Генераторы Проектов с тайтлом.
+
+И ещё одна экстра ссылка.
+
+# Заголовок 4 { #header-4 }
+
+Ссылка на якорь: Заголовок 2
+
+# Заголовок со ссылкой { #header-with-link }
+
+Немного текста
diff --git a/scripts/tests/test_translation_fixer/test_html_links/data/translated_doc_number_lt.md b/scripts/tests/test_translation_fixer/test_html_links/data/translated_doc_number_lt.md
new file mode 100644
index 000000000..e2b36b688
--- /dev/null
+++ b/scripts/tests/test_translation_fixer/test_html_links/data/translated_doc_number_lt.md
@@ -0,0 +1,19 @@
+# Заголовок 1 { #header-1 }
+
+Немного текста со ссылкой на FastAPI.
+
+## Заголовок 2 { #header-2 }
+
+Две ссылки здесь: How to и Project Generators.
+
+### Заголовок 3 { #header-3 }
+
+Ещё ссылка: **FastAPI** Генераторы Проектов с тайтлом.
+
+# Заголовок 4 { #header-4 }
+
+Ссылка на якорь: Заголовок 2
+
+# Заголовок с потерянной ссылкой { #header-with-link }
+
+Немного текста
diff --git a/scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py b/scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py
new file mode 100644
index 000000000..e201555fa
--- /dev/null
+++ b/scripts/tests/test_translation_fixer/test_html_links/test_html_links_number_mismatch.py
@@ -0,0 +1,56 @@
+from pathlib import Path
+
+import pytest
+from typer.testing import CliRunner
+
+from scripts.translation_fixer import cli
+
+data_path = Path(
+ "scripts/tests/test_translation_fixer/test_html_links/data"
+).absolute()
+
+
+@pytest.mark.parametrize(
+ "copy_test_files",
+ [(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_gt.md")],
+ indirect=True,
+)
+def test_gt(runner: CliRunner, root_dir: Path, copy_test_files):
+ result = runner.invoke(
+ cli,
+ ["fix-pages", "docs/lang/docs/doc.md"],
+ )
+ assert result.exit_code == 1, result.output
+
+ fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
+ expected_content = Path(f"{data_path}/translated_doc_number_gt.md").read_text()
+
+ assert fixed_content == expected_content # Translated doc remains unchanged
+ assert "Error processing docs/lang/docs/doc.md" in result.output
+ assert (
+ "Number of HTML links does not match the number "
+ "in the original document (7 vs 6)"
+ ) in result.output
+
+
+@pytest.mark.parametrize(
+ "copy_test_files",
+ [(f"{data_path}/en_doc.md", f"{data_path}/translated_doc_number_lt.md")],
+ indirect=True,
+)
+def test_lt(runner: CliRunner, root_dir: Path, copy_test_files):
+ result = runner.invoke(
+ cli,
+ ["fix-pages", "docs/lang/docs/doc.md"],
+ )
+ # assert result.exit_code == 1, result.output
+
+ fixed_content = (root_dir / "docs" / "lang" / "docs" / "doc.md").read_text()
+ expected_content = Path(f"{data_path}/translated_doc_number_lt.md").read_text()
+
+ assert fixed_content == expected_content # Translated doc remains unchanged
+ assert "Error processing docs/lang/docs/doc.md" in result.output
+ assert (
+ "Number of HTML links does not match the number "
+ "in the original document (5 vs 6)"
+ ) in result.output