v0.5.3
Example document / build (push) Has been cancelled
Python application / build (push) Has been cancelled

- Мелкие исправления увеличивающие работу конвертера
This commit is contained in:
Igor20264
2026-09-10 10:50:15 +03:00
parent 658036f920
commit f7136bd8bd
95 changed files with 7165 additions and 8771 deletions
+28
View File
@@ -26,6 +26,7 @@ SPECIAL_UNNUMBERED = {
}
HEADING_RE = re.compile(r"^(#{1,6})\s+(\*?)(.+)$", re.M)
EMPTY_HEADING_RE = re.compile(r"^(#{1,6})[^\n\S]*\*?[^\n\S]*$", re.M)
FOOTNOTE_RE = re.compile(r"\[\^[^\]]+\]")
RIS_RE = re.compile(r"(?i)\bрис\.")
TABL_RE = re.compile(r"(?i)\bтабл\.")
@@ -199,6 +200,19 @@ def check_special_headings(text: str) -> list[Issue]:
return issues
def check_empty_headings(text: str) -> list[Issue]:
"""Заголовок без текста: пронумерованный, но безымянный раздел в содержании."""
issues = []
for m in EMPTY_HEADING_RE.finditer(text):
issues.append(Issue(
"heading.empty", "warning",
"Заголовок без текста: разделы, подразделы и пункты должны иметь "
"заголовки, чётко и кратко отражающие их содержание",
_line_of(text, m.start()),
))
return issues
def check_forbidden_abbreviations(text: str) -> list[Issue]:
issues = []
for m in RIS_RE.finditer(text):
@@ -399,6 +413,8 @@ def check_continuation_hints(
*,
table_continuation: str = "off",
listing_continuation: str = "off",
syntax_highlighting: bool = False,
strict: bool = False,
) -> list[Issue]:
"""Warn that Word cannot auto-insert «Продолжение…» when mode is off/soft."""
issues: list[Issue] = []
@@ -422,6 +438,13 @@ def check_continuation_hints(
"Длинный листинг: Word сам не вставит «Продолжение Листинга N». "
"Варианты: --listing-continuation word или caption.",
))
if syntax_highlighting:
issues.append(Issue(
"listing.syntax_highlighting",
"error" if strict else "warning",
"Подсветка синтаксиса задаёт полужирный и цвет в содержимом листинга. "
"Табл. 4.1 методички требует «Начертание Обычный», «Цвет текста Авто (чёрный)».",
))
return issues
@@ -490,11 +513,14 @@ def check_markdown(
*,
table_continuation: str = "off",
listing_continuation: str = "off",
syntax_highlighting: bool = False,
strict: bool = False,
) -> list[Issue]:
profile = get_profile(doc_type)
issues: list[Issue] = []
issues.extend(check_structure(text, profile))
issues.extend(check_special_headings(text))
issues.extend(check_empty_headings(text))
issues.extend(check_pis_headings(text, profile))
issues.extend(check_forbidden_abbreviations(text))
if profile.require_intro_conclusion:
@@ -507,6 +533,8 @@ def check_markdown(
text,
table_continuation=table_continuation,
listing_continuation=listing_continuation,
syntax_highlighting=syntax_highlighting,
strict=strict,
))
return issues