v0.5.3
- Мелкие исправления увеличивающие работу конвертера
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user