/
ArtKAtMan
/
arbat
Обзор
Документация
Войти
/
ArtKAtMan
/
arbat
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
scripts/fix-qa-split.py
46 строк
1 KB
Mavis (M3)
fix: article markdown — bold/FAQ rendering, wider container, related grid 4-col
10 июл 2026, 18:41
10 июл 2026, 18:41
a416f50
Код
Авторство
О чём код?
"""Third pass: ensure each FAQ question and answer is on its own line(s). Targets lines like: ** Вопрос? ** Ответ сразу. or ** Вопрос? ** Ответ (тут уже есть пустая строка — норм). We split '**Q?** A...' into: ** Q? ** <blank> A """ import re from pathlib import Path CONTENT_DIR = Path('src/content/articles') # Match a line that has `**...?**` (with optional internal spaces) followed by # the answer text on the same line (anything until newline). QA_SAME_LINE = re.compile(r'^(>\s*)?(\*\*[^*]+\?\*\*)\s+(.+)$', re.MULTILINE) def fix(text: str) -> str: def repl(m: re.Match) -> str: quote = m.group(1) or '' q = m.group(2) a = m.group(3).strip() return f'{quote}{q}\n\n{quote}{a}' return QA_SAME_LINE.sub(repl, text) def main(): for f in sorted(CONTENT_DIR.glob('*.md')): text = f.read_text(encoding='utf-8') new = fix(text) if new != text: f.write_text(new, encoding='utf-8') print(f'qa-split: {f.name}') else: print(f'no change: {f.name}') if __name__ == '__main__': main()